注销账号:登录弹窗
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
180116F9279E8C4C00F2CBC0 /* PLTimeUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 180116F8279E8C4C00F2CBC0 /* PLTimeUtil.m */; };
|
||||
180116FC279E8CCE00F2CBC0 /* NVDate.m in Sources */ = {isa = PBXBuildFile; fileRef = 180116FA279E8CCE00F2CBC0 /* NVDate.m */; };
|
||||
180806D827293794001FD836 /* NSObject+MJExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 180806D727293794001FD836 /* NSObject+MJExtension.m */; };
|
||||
180806FB2729A354001FD836 /* ThemeColor+Room.m in Sources */ = {isa = PBXBuildFile; fileRef = 180806FA2729A354001FD836 /* ThemeColor+Room.m */; };
|
||||
1808072D2731598F001FD836 /* XPNetImageYYLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1808072C2731598F001FD836 /* XPNetImageYYLabel.m */; };
|
||||
@@ -389,6 +391,10 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
180116F7279E8C4C00F2CBC0 /* PLTimeUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLTimeUtil.h; sourceTree = "<group>"; };
|
||||
180116F8279E8C4C00F2CBC0 /* PLTimeUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PLTimeUtil.m; sourceTree = "<group>"; };
|
||||
180116FA279E8CCE00F2CBC0 /* NVDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NVDate.m; sourceTree = "<group>"; };
|
||||
180116FB279E8CCE00F2CBC0 /* NVDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NVDate.h; sourceTree = "<group>"; };
|
||||
180806D627293794001FD836 /* NSObject+MJExtension.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSObject+MJExtension.h"; sourceTree = "<group>"; };
|
||||
180806D727293794001FD836 /* NSObject+MJExtension.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSObject+MJExtension.m"; sourceTree = "<group>"; };
|
||||
180806DA27297269001FD836 /* MicroViewProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroViewProtocol.h; sourceTree = "<group>"; };
|
||||
@@ -1099,6 +1105,17 @@
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
180116F6279E8C3100F2CBC0 /* Date */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
180116FB279E8CCE00F2CBC0 /* NVDate.h */,
|
||||
180116FA279E8CCE00F2CBC0 /* NVDate.m */,
|
||||
180116F7279E8C4C00F2CBC0 /* PLTimeUtil.h */,
|
||||
180116F8279E8C4C00F2CBC0 /* PLTimeUtil.m */,
|
||||
);
|
||||
path = Date;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
18486210271EA9A5005FC5DC /* RTC */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1498,6 +1515,7 @@
|
||||
189DD5A726DFA09700AB55B1 /* Tool */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
180116F6279E8C3100F2CBC0 /* Date */,
|
||||
E82D5C77276B25B000858D6D /* SpriteSheetManager */,
|
||||
E865964E2701A1A900846EBD /* StatisticsService */,
|
||||
E89DA6612700590A008483C1 /* IAPHelper */,
|
||||
@@ -3178,6 +3196,7 @@
|
||||
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */,
|
||||
E890BC07273CF1800007C46B /* XPGiftCountCollectionViewCell.m in Sources */,
|
||||
E8EEB91126FC6AE2007C6EBA /* XPMineUserInfoEditProtocol.h in Sources */,
|
||||
180116FC279E8CCE00F2CBC0 /* NVDate.m in Sources */,
|
||||
E8EEB90326FC31DC007C6EBA /* XPMineUserInfoProtocol.h in Sources */,
|
||||
E8232603274E4AA0003A3332 /* ThemeColor+UserCard.m in Sources */,
|
||||
E87A24F1272935920086A794 /* XPMessageRemoteExtModel.m in Sources */,
|
||||
@@ -3240,6 +3259,7 @@
|
||||
E81C279626EB39CC0031E639 /* LoginForgetPasswordPresent.m in Sources */,
|
||||
18EE3FF42750FA3700A452BF /* UIView+NIM.m in Sources */,
|
||||
E8A03DFF27635F960098D9EA /* XPRoomCandyGiftView.m in Sources */,
|
||||
180116F9279E8C4C00F2CBC0 /* PLTimeUtil.m in Sources */,
|
||||
E8252FEE27687DF1002B3164 /* ActivityInfoModel.m in Sources */,
|
||||
E8AC723526F49939007D6E91 /* XPMineNotificaPresenter.m in Sources */,
|
||||
18EE3FE22750C29D00A452BF /* NIMBadgeView.m in Sources */,
|
||||
|
@@ -84,6 +84,9 @@
|
||||
case 1415: // 未完善用户信息
|
||||
[[self getView] completeUserInfo];
|
||||
return;
|
||||
case 3009: // 账号已注销
|
||||
[[self getView] accountCanceled:data.data];
|
||||
return;
|
||||
}
|
||||
|
||||
if (toast) {
|
||||
|
@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)tokenInvalid;
|
||||
- (void)completeUserInfo;
|
||||
- (void)accountCanceled:(NSDictionary *)data;
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -11,6 +11,9 @@
|
||||
#import "LoginViewController.h"
|
||||
#import "BaseNavigationController.h"
|
||||
#import "LoginFullInfoViewController.h"
|
||||
#import "TTPopup.h"
|
||||
#import "PLTimeUtil.h"
|
||||
#import "ThemeColor.h"
|
||||
|
||||
@interface MvpViewController ()
|
||||
|
||||
@@ -41,6 +44,26 @@
|
||||
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)accountCanceled:(NSDictionary *)data {
|
||||
NSString *date = [NSString stringWithFormat:@"%.0f",[[data objectForKey:@"cancelDate"]doubleValue]];
|
||||
NSString *dateDes = [NSString stringWithFormat:@"注销时间:%@", [PLTimeUtil getDateWithYYMMDD:date]];
|
||||
NSString *msg = [NSString stringWithFormat:@"%@\n\n请联系客服(微信:yinyoukefu01)处理哦~", dateDes];
|
||||
TTAlertMessageAttributedConfig *dateAttrConfig = [[TTAlertMessageAttributedConfig alloc] init];
|
||||
dateAttrConfig.text = dateDes;
|
||||
dateAttrConfig.color = ThemeColor.appMainColor;
|
||||
|
||||
TTAlertConfig *config = [[TTAlertConfig alloc] init];
|
||||
config.title = @"该账号已注销";
|
||||
config.message = msg;
|
||||
config.messageAttributedConfig = @[dateAttrConfig];
|
||||
|
||||
[TTPopup alertWithConfig:config confirmHandler:^{
|
||||
|
||||
} cancelHandler:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)completeUserInfo {
|
||||
LoginFullInfoViewController * bindPhoneVC = [[LoginFullInfoViewController alloc] init];
|
||||
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
|
||||
@@ -48,5 +71,4 @@
|
||||
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
95
xplan-ios/Base/Tool/Date/NVDate.h
Normal file
95
xplan-ios/Base/Tool/Date/NVDate.h
Normal file
@@ -0,0 +1,95 @@
|
||||
//
|
||||
// NVDate.h
|
||||
//
|
||||
// Created by Noval Agung Prayogo on 2/5/14.
|
||||
// Copyright (c) 2014 Noval Agung Prayogo. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, NVDayUnit) {
|
||||
NVDayUnitSunday = 1,
|
||||
NVDayUnitMonday = 2,
|
||||
NVDayUnitTuesday = 3,
|
||||
NVDayUnitWednesday = 4,
|
||||
NVDayUnitThursday = 5,
|
||||
NVDayUnitFriday = 6,
|
||||
NVDayUnitSaturday = 7
|
||||
};
|
||||
|
||||
typedef NS_OPTIONS(NSUInteger, NVMonthUnit) {
|
||||
NVMonthUnitJanuary = 1,
|
||||
NVMonthUnitFebruary = 2,
|
||||
NVMonthUnitMarch = 3,
|
||||
NVMonthUnitApril = 4,
|
||||
NVMonthUnitMay = 5,
|
||||
NVMonthUnitJune = 6,
|
||||
NVMonthUnitJuly = 7,
|
||||
NVMonthUnitAugust = 8,
|
||||
NVMonthUnitSeptember = 9,
|
||||
NVMonthUnitOctober = 10,
|
||||
NVMonthUnitNovember = 11,
|
||||
NVMonthUnitDecember = 12,
|
||||
};
|
||||
|
||||
@interface NVDate : NSObject
|
||||
|
||||
- (id)initUsingToday;
|
||||
- (id)initUsingDate:(NSDate *)date;
|
||||
- (id)initUsingYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day;
|
||||
- (id)initUsingYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second;
|
||||
- (id)initUsingString:(NSString *)stringDate;
|
||||
- (id)initUsingString:(NSString *)stringDate withFormat:(NSString *)dateFormat;
|
||||
- (id)initUsingSeconds:(NSInteger)seconds;
|
||||
|
||||
- (NSDate *)date;
|
||||
|
||||
- (NSString *)stringValue;
|
||||
- (NSString *)stringValueWithFormat:(NSString *)dateFormat;
|
||||
|
||||
- (instancetype)zeroTime;
|
||||
|
||||
- (instancetype)previousDay;
|
||||
- (instancetype)previousDays:(NSInteger)days;
|
||||
- (instancetype)nextDay;
|
||||
- (instancetype)nextDays:(NSInteger)days;
|
||||
|
||||
- (instancetype)previousWeek;
|
||||
- (instancetype)previousWeeks:(NSInteger)weeks;
|
||||
- (instancetype)nextWeek;
|
||||
- (instancetype)nextWeeks:(NSInteger)weeks;
|
||||
|
||||
- (instancetype)previousMonth;
|
||||
- (instancetype)previousMonths:(NSInteger)months;
|
||||
- (instancetype)nextMonth;
|
||||
- (instancetype)nextMonths:(NSInteger)months;
|
||||
|
||||
- (instancetype)previousYear;
|
||||
- (instancetype)previousYears:(NSInteger)years;
|
||||
- (instancetype)nextYear;
|
||||
- (instancetype)nextYears:(NSInteger)years;
|
||||
|
||||
- (instancetype)firstDayOfMonth;
|
||||
- (instancetype)lastDayOfMonth;
|
||||
|
||||
- (instancetype)firstMonthOfYear;
|
||||
- (instancetype)lastMonthOfYear;
|
||||
|
||||
- (instancetype)previousDayOfDayName:(NVDayUnit)dayUnit;
|
||||
- (instancetype)nextDayOfDayName:(NVDayUnit)dayUnit;
|
||||
|
||||
- (BOOL)isCurrentDayName:(NVDayUnit)dayUnit;
|
||||
- (BOOL)isCurrentMonthName:(NVMonthUnit)monthUnit;
|
||||
|
||||
@property NSString *dateFormatUsingString;
|
||||
@property NSDateFormatterStyle dateFormatUsingStyle;
|
||||
@property NSDateFormatterStyle timeFormatUsingStyle;
|
||||
@property NSInteger year;
|
||||
@property NSInteger month;
|
||||
@property (readonly) NSInteger week;
|
||||
@property NSInteger day;
|
||||
@property NSInteger hour;
|
||||
@property NSInteger minute;
|
||||
@property NSInteger second;
|
||||
|
||||
@end
|
394
xplan-ios/Base/Tool/Date/NVDate.m
Normal file
394
xplan-ios/Base/Tool/Date/NVDate.m
Normal file
@@ -0,0 +1,394 @@
|
||||
//
|
||||
// NVDate.m
|
||||
//
|
||||
// Created by Noval Agung Prayogo on 2/5/14.
|
||||
// Copyright (c) 2014 Noval Agung Prayogo. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NVDate.h"
|
||||
|
||||
@implementation NVDate {
|
||||
NSDateFormatter *_dateFormatter;
|
||||
NSCalendar *_calendar;
|
||||
NSDate *_date;
|
||||
NSCalendarUnit _dateTimeCalendarUnit;
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
if (self = [super init]) {
|
||||
_dateFormatter = [[NSDateFormatter alloc] init];
|
||||
_dateFormatter.dateStyle = NSDateFormatterFullStyle;
|
||||
_dateFormatter.timeStyle = NSDateFormatterFullStyle;
|
||||
|
||||
_calendar = [NSCalendar currentCalendar];
|
||||
|
||||
_date = [[NSDate alloc] init];
|
||||
|
||||
_dateTimeCalendarUnit = (NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initUsingToday {
|
||||
if (self = [self init]) {
|
||||
_date = [NSDate date];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initUsingString:(NSString *)stringDate {
|
||||
if (self = [self init]) {
|
||||
_date = [_dateFormatter dateFromString:stringDate];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initUsingString:(NSString *)stringDate withFormat:(NSString *)dateFormat {
|
||||
if (self = [self init]) {
|
||||
_dateFormatter.dateFormat = dateFormat;
|
||||
_date = [_dateFormatter dateFromString:stringDate];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initUsingYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day {
|
||||
if (self = [self init]) {
|
||||
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
||||
dateComponents.year = year;
|
||||
dateComponents.month = month;
|
||||
dateComponents.day = day;
|
||||
_date = [_calendar dateFromComponents:dateComponents];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initUsingYear:(NSInteger)year month:(NSInteger)month day:(NSInteger)day hour:(NSInteger)hour minute:(NSInteger)minute second:(NSInteger)second {
|
||||
if (self = [self init]) {
|
||||
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
||||
dateComponents.year = year;
|
||||
dateComponents.month = month;
|
||||
dateComponents.day = day;
|
||||
dateComponents.hour = hour;
|
||||
dateComponents.minute = minute;
|
||||
dateComponents.second = second;
|
||||
_date = [_calendar dateFromComponents:dateComponents];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initUsingDate:(NSDate *)date {
|
||||
if (self = [self init]) {
|
||||
_date = date;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initUsingSeconds:(NSInteger)seconds {
|
||||
if (self = [self init]) {
|
||||
_date = [NSDate dateWithTimeIntervalSinceReferenceDate:seconds];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSDate *)date {
|
||||
return _date;
|
||||
}
|
||||
|
||||
- (NSString *)stringValue {
|
||||
return [_dateFormatter stringFromDate:_date];
|
||||
}
|
||||
|
||||
- (NSString *)stringValueWithFormat:(NSString *)dateFormat {
|
||||
NSDateFormatter *localDateFormatter = [_dateFormatter copy];
|
||||
localDateFormatter.dateFormat = dateFormat;
|
||||
|
||||
return [localDateFormatter stringFromDate:_date];
|
||||
}
|
||||
|
||||
- (instancetype)zeroTime {
|
||||
NSDateComponents *dateComponents = [_calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:_date];
|
||||
dateComponents.hour = 0;
|
||||
dateComponents.minute = 0;
|
||||
dateComponents.second = 0;
|
||||
|
||||
_date = [_calendar dateFromComponents:dateComponents];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setDateFormatUsingString:(NSString *)dateFormatUsingString {
|
||||
_dateFormatter.dateFormat = dateFormatUsingString;
|
||||
}
|
||||
|
||||
- (NSString *)dateFormatUsingString {
|
||||
return _dateFormatter.dateFormat;
|
||||
}
|
||||
|
||||
- (void)setDateFormatUsingStyle:(NSDateFormatterStyle)dateFormatUsingStyle {
|
||||
_dateFormatter.dateStyle = dateFormatUsingStyle;
|
||||
}
|
||||
|
||||
- (NSDateFormatterStyle)dateFormatUsingStyle {
|
||||
return _dateFormatter.dateStyle;
|
||||
}
|
||||
|
||||
- (void)setTimeFormatUsingStyle:(NSDateFormatterStyle)timeFormatUsingStyle {
|
||||
_dateFormatter.timeStyle = timeFormatUsingStyle;
|
||||
}
|
||||
|
||||
- (NSDateFormatterStyle)timeFormatUsingStyle {
|
||||
return _dateFormatter.timeStyle;
|
||||
}
|
||||
|
||||
- (instancetype)daysCalculate:(NSInteger)days isForward:(BOOL)isForward {
|
||||
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
||||
dateComponents.day = days * (isForward ? 1 : -1);
|
||||
_date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)previousDay {
|
||||
return [self previousDays:1];
|
||||
}
|
||||
|
||||
- (instancetype)previousDays:(NSInteger)days {
|
||||
return [self daysCalculate:days isForward:NO];
|
||||
}
|
||||
|
||||
- (instancetype)nextDay {
|
||||
return [self nextDays:1];
|
||||
}
|
||||
|
||||
- (instancetype)nextDays:(NSInteger)days {
|
||||
return [self daysCalculate:days isForward:YES];
|
||||
}
|
||||
|
||||
- (instancetype)weeksCalculate:(NSInteger)weeks isForward:(BOOL)isForward {
|
||||
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
||||
dateComponents.day = (7 * weeks) * (isForward ? 1 : -1);
|
||||
_date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)previousWeek {
|
||||
return [self previousWeeks:1];
|
||||
}
|
||||
|
||||
- (instancetype)previousWeeks:(NSInteger)weeks {
|
||||
return [self weeksCalculate:weeks isForward:NO];
|
||||
}
|
||||
|
||||
- (instancetype)nextWeek {
|
||||
return [self nextWeeks:1];
|
||||
}
|
||||
|
||||
- (instancetype)nextWeeks:(NSInteger)weeks {
|
||||
return [self weeksCalculate:weeks isForward:YES];
|
||||
}
|
||||
|
||||
- (instancetype)monthsCalculate:(NSInteger)months isForward:(BOOL)isForward {
|
||||
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
||||
dateComponents.month = months * (isForward ? 1 : -1);
|
||||
_date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)previousMonth {
|
||||
return [self previousMonths:1];
|
||||
}
|
||||
|
||||
- (instancetype)previousMonths:(NSInteger)months {
|
||||
return [self monthsCalculate:months isForward:NO];
|
||||
}
|
||||
|
||||
- (instancetype)nextMonth {
|
||||
return [self nextMonths:1];
|
||||
}
|
||||
|
||||
- (instancetype)nextMonths:(NSInteger)months {
|
||||
return [self monthsCalculate:months isForward:YES];
|
||||
}
|
||||
|
||||
- (instancetype)yearsCalculate:(NSInteger)years isForward:(BOOL)isForward {
|
||||
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
||||
dateComponents.year = years * (isForward ? 1 : -1);
|
||||
_date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)previousYear {
|
||||
return [self previousYears:1];
|
||||
}
|
||||
|
||||
- (instancetype)previousYears:(NSInteger)years {
|
||||
return [self yearsCalculate:years isForward:NO];
|
||||
}
|
||||
|
||||
- (instancetype)nextYear {
|
||||
return [self nextYears:1];
|
||||
}
|
||||
|
||||
- (instancetype)nextYears:(NSInteger)years {
|
||||
return [self yearsCalculate:years isForward:YES];
|
||||
}
|
||||
|
||||
- (instancetype)firstDayOfMonth {
|
||||
NSDateComponents *dateComponents = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
dateComponents.day = 1;
|
||||
_date = [_calendar dateFromComponents:dateComponents];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)lastDayOfMonth {
|
||||
NSDateComponents *dateComponents;
|
||||
NSDate *date;
|
||||
|
||||
dateComponents = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
dateComponents.day = 1;
|
||||
date = [_calendar dateFromComponents:dateComponents];
|
||||
dateComponents = [[NSDateComponents alloc] init];
|
||||
dateComponents.month = 1;
|
||||
date = [_calendar dateByAddingComponents:dateComponents toDate:date options:0];
|
||||
dateComponents = [[NSDateComponents alloc] init];
|
||||
dateComponents.day = -1;
|
||||
_date = [_calendar dateByAddingComponents:dateComponents toDate:date options:0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)firstMonthOfYear {
|
||||
NSDateComponents *dateComponents = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
dateComponents.month = NVMonthUnitJanuary;
|
||||
_date = [_calendar dateFromComponents:dateComponents];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)lastMonthOfYear {
|
||||
NSDateComponents *dateComponents = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
dateComponents.month = NVMonthUnitDecember;
|
||||
_date = [_calendar dateFromComponents:dateComponents];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)previousDayOfDayName:(NVDayUnit)dayUnit {
|
||||
NSInteger currentWeekDay = [_calendar components:_dateTimeCalendarUnit fromDate:_date].weekday;
|
||||
|
||||
if (currentWeekDay == dayUnit)
|
||||
return [self previousWeek];
|
||||
|
||||
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
||||
|
||||
if (currentWeekDay > dayUnit)
|
||||
dateComponents.day = -(currentWeekDay - dayUnit);
|
||||
else
|
||||
dateComponents.day = -currentWeekDay - (7 - dayUnit);
|
||||
|
||||
_date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)nextDayOfDayName:(NVDayUnit)dayUnit {
|
||||
NSInteger currentWeekDay = [_calendar components:_dateTimeCalendarUnit fromDate:_date].weekday;
|
||||
|
||||
if (currentWeekDay == dayUnit)
|
||||
return [self nextWeek];
|
||||
|
||||
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
||||
|
||||
if (currentWeekDay < dayUnit)
|
||||
dateComponents.day = dayUnit - currentWeekDay;
|
||||
else
|
||||
dateComponents.day = -currentWeekDay + dayUnit;
|
||||
|
||||
_date = [_calendar dateByAddingComponents:dateComponents toDate:_date options:0];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isCurrentDayName:(NVDayUnit)dayUnit {
|
||||
return ([_calendar components:_dateTimeCalendarUnit fromDate:_date].weekday == dayUnit);
|
||||
}
|
||||
|
||||
- (BOOL)isCurrentMonthName:(NVMonthUnit)monthUnit {
|
||||
return ([_calendar components:_dateTimeCalendarUnit fromDate:_date].month == monthUnit);
|
||||
}
|
||||
|
||||
- (NSInteger)year {
|
||||
return [_calendar components:_dateTimeCalendarUnit fromDate:_date].year;
|
||||
}
|
||||
|
||||
- (void)setYear:(NSInteger)year {
|
||||
NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
components.year = year;
|
||||
|
||||
_date = [_calendar dateFromComponents:components];
|
||||
}
|
||||
|
||||
- (NSInteger)month {
|
||||
return [_calendar components:_dateTimeCalendarUnit fromDate:_date].month;
|
||||
}
|
||||
|
||||
- (void)setMonth:(NSInteger)month {
|
||||
NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
components.month = month;
|
||||
|
||||
_date = [_calendar dateFromComponents:components];
|
||||
}
|
||||
|
||||
- (NSInteger)week {
|
||||
return [_calendar components:_dateTimeCalendarUnit fromDate:_date].weekday;
|
||||
}
|
||||
|
||||
- (NSInteger)day {
|
||||
return [_calendar components:_dateTimeCalendarUnit fromDate:_date].day;
|
||||
}
|
||||
|
||||
- (void)setDay:(NSInteger)day {
|
||||
NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
components.day = day;
|
||||
|
||||
_date = [_calendar dateFromComponents:components];
|
||||
}
|
||||
|
||||
- (NSInteger)hour {
|
||||
return [_calendar components:_dateTimeCalendarUnit fromDate:_date].hour;
|
||||
}
|
||||
|
||||
- (void)setHour:(NSInteger)hour {
|
||||
NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
components.hour = hour;
|
||||
|
||||
_date = [_calendar dateFromComponents:components];
|
||||
}
|
||||
|
||||
- (NSInteger)minute {
|
||||
return [_calendar components:_dateTimeCalendarUnit fromDate:_date].minute;
|
||||
}
|
||||
|
||||
- (void)setMinute:(NSInteger)minute {
|
||||
NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
components.minute = minute;
|
||||
|
||||
_date = [_calendar dateFromComponents:components];
|
||||
}
|
||||
|
||||
- (NSInteger)second {
|
||||
return [_calendar components:_dateTimeCalendarUnit fromDate:_date].second;
|
||||
}
|
||||
|
||||
- (void)setSecond:(NSInteger)second {
|
||||
NSDateComponents *components = [_calendar components:_dateTimeCalendarUnit fromDate:_date];
|
||||
components.second = second;
|
||||
|
||||
_date = [_calendar dateFromComponents:components];
|
||||
}
|
||||
|
||||
@end
|
49
xplan-ios/Base/Tool/Date/PLTimeUtil.h
Normal file
49
xplan-ios/Base/Tool/Date/PLTimeUtil.h
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// PLTimeUtil.h
|
||||
// YYMobile
|
||||
//
|
||||
// Created by penglong on 14/10/28.
|
||||
// Copyright (c) 2014年 YY.inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface PLTimeUtil : NSObject
|
||||
|
||||
/**
|
||||
* 根据秒数获取倒计时时间
|
||||
*
|
||||
* @param second 秒
|
||||
*
|
||||
* @return 格式为 01:02:00
|
||||
*/
|
||||
+ (NSString *)getTimeWithSecond:(NSUInteger)second;
|
||||
|
||||
+ (NSDate *)getDateWithCompleteTime:(NSString *)time;
|
||||
|
||||
+ (NSDate *)getDateWithTime:(NSString *)time;
|
||||
|
||||
+ (NSDate *)getDateWithYmd:(NSString *)time;
|
||||
|
||||
+ (NSString *)getDateWithHHMMSS:(NSString *)time;
|
||||
|
||||
+ (NSString *)getDateWithYYMMDD:(NSString *)time;
|
||||
|
||||
+ (NSString *)getDateWithYYMM:(NSString *)time;
|
||||
|
||||
+ (NSDate *)getDateWithYearMonthDay:(NSString *)time;
|
||||
|
||||
+ (NSString *)getMonthDayContent:(NSDate *)date;
|
||||
|
||||
+ (NSString *)getYYMMWithDate:(NSDate *)date;
|
||||
|
||||
+ (NSString *)getYYMMDDWithDate:(NSDate *)date;
|
||||
|
||||
+ (NSString *)getYYMMDDWithDateFormatter:(NSDate *)date;
|
||||
|
||||
+ (NSString *)getDateWithTotalTimeWith:(NSString *)time;
|
||||
|
||||
+ (NSString *)getNowTimeTimestampMillisecond;
|
||||
|
||||
@end
|
||||
|
234
xplan-ios/Base/Tool/Date/PLTimeUtil.m
Normal file
234
xplan-ios/Base/Tool/Date/PLTimeUtil.m
Normal file
@@ -0,0 +1,234 @@
|
||||
//
|
||||
// PLTimeUtil.m
|
||||
// YYMobile
|
||||
//
|
||||
// Created by penglong on 14/10/28.
|
||||
// Copyright (c) 2014年 YY.inc. All rights reserved.
|
||||
//
|
||||
|
||||
#import "PLTimeUtil.h"
|
||||
#import "NVDate.h"
|
||||
#import "YYUtility.h"
|
||||
@implementation PLTimeUtil
|
||||
|
||||
+ (NSString *)getTimeWithSecond:(NSUInteger)second
|
||||
{
|
||||
NSUInteger hours = second / 3600;
|
||||
NSUInteger minutes = (second % 3600) / 60;
|
||||
NSUInteger seconds = second % 60;
|
||||
return [NSString stringWithFormat:@"%@:%@:%@",[self getConent:hours],
|
||||
[self getConent:minutes],[self getConent:seconds]];
|
||||
}
|
||||
|
||||
+ (NSString *)getConent:(NSUInteger)count
|
||||
{
|
||||
if(count >= 10){
|
||||
return [NSString stringWithFormat:@"%lu",(unsigned long)count];
|
||||
}
|
||||
return [NSString stringWithFormat:@"0%lu",(unsigned long)count];
|
||||
}
|
||||
|
||||
+(NSDate *)getDateWithYmd:(NSString *)time
|
||||
{
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setDateFormat:@"yyyy:MM:dd"];
|
||||
NSDate* date = [dateFormatter dateFromString:time];
|
||||
return date;
|
||||
}
|
||||
|
||||
+(NSDate *)getDateWithYearMonthDay:(NSString *)time
|
||||
{
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
|
||||
NSDate* date = [dateFormatter dateFromString:time];
|
||||
return date;
|
||||
}
|
||||
|
||||
+ (NSDate *)getDateWithCompleteTime:(NSString *)time
|
||||
{
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setDateFormat:@"yyyy:MM:dd HH:mm:ss"];
|
||||
NSDate* date = [dateFormatter dateFromString:time];
|
||||
return date;
|
||||
}
|
||||
|
||||
+ (NSDate *)getDateWithTime:(NSString *)time
|
||||
{
|
||||
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
||||
[dateFormatter setDateFormat:@"HH:mm:ss"];
|
||||
NSDate* date = [dateFormatter dateFromString:time];
|
||||
return date;
|
||||
}
|
||||
|
||||
+ (NSString *)getMonthDayContent:(NSDate *)date
|
||||
{
|
||||
NVDate *currentNVDate = [[NVDate alloc] initUsingDate:date];
|
||||
|
||||
NSString *month = [self getContent:currentNVDate.month];
|
||||
NSString *day = [self getContent:currentNVDate.day];
|
||||
|
||||
NSString *content = [NSString stringWithFormat:@"%@-%@",month,day];
|
||||
return content;
|
||||
}
|
||||
|
||||
+ (NSString *)getContent:(NSUInteger)count
|
||||
{
|
||||
if(count >= 10){
|
||||
return [NSString stringWithFormat:@"%lu",(unsigned long)count];
|
||||
}
|
||||
return [NSString stringWithFormat:@"0%lu",(unsigned long)count];
|
||||
}
|
||||
|
||||
+ (NSString *)getYYMMDDWithDate:(NSDate *)date {
|
||||
// NSTimeZone *zome = [NSTimeZone systemTimeZone];
|
||||
// NSTimeInterval seconds1 = [zome secondsFromGMTForDate:date];
|
||||
// NSDate *date2 = [date dateByAddingTimeInterval:seconds1];
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
|
||||
NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
|
||||
[formatter setTimeZone:timeZone];
|
||||
formatter.dateFormat = @"yyyy-MM-dd";
|
||||
NSString *dateStr = [formatter stringFromDate:date];
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
+ (NSString *)getYYMMDDWithDateFormatter:(NSDate *)date {
|
||||
// NSTimeZone *zome = [NSTimeZone systemTimeZone];
|
||||
// NSTimeInterval seconds1 = [zome secondsFromGMTForDate:date];
|
||||
// NSDate *date2 = [date dateByAddingTimeInterval:seconds1];
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
|
||||
NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
|
||||
[formatter setTimeZone:timeZone];
|
||||
formatter.dateFormat = @"yyyy年MM月dd日";
|
||||
NSString *dateStr = [formatter stringFromDate:date];
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
|
||||
+ (NSString *)getYYMMWithDate:(NSDate *)date {
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
|
||||
NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
|
||||
[formatter setTimeZone:timeZone];
|
||||
formatter.dateFormat = @"YYYY年MM月";
|
||||
NSString *dateStr = [formatter stringFromDate:date];
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
+ (NSString *)getDateWithYYMMDD:(NSString *)time {
|
||||
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
|
||||
[formatter setDateStyle:NSDateFormatterMediumStyle];
|
||||
[formatter setTimeStyle:NSDateFormatterShortStyle];
|
||||
[formatter setDateFormat:@"YYYY年MM月dd日"];
|
||||
// 毫秒值转化为秒
|
||||
NSString * times;
|
||||
if ([self is32bit] && [[YYUtility systemVersion] floatValue] <= 10.0) {
|
||||
times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)];
|
||||
}else{
|
||||
times = time;
|
||||
}
|
||||
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times longLongValue]/ 1000.0];
|
||||
NSString* dateString = [formatter stringFromDate:date];
|
||||
return dateString;
|
||||
}
|
||||
|
||||
+ (BOOL)is32bit
|
||||
|
||||
{
|
||||
|
||||
#if defined(__LP64__) && __LP64__
|
||||
|
||||
return NO;
|
||||
|
||||
#else
|
||||
|
||||
return YES;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
+ (NSString *)getDateWithYYMM:(NSString *)time {
|
||||
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
|
||||
[formatter setDateStyle:NSDateFormatterMediumStyle];
|
||||
[formatter setTimeStyle:NSDateFormatterShortStyle];
|
||||
[formatter setDateFormat:@"yyyy年MM月"];
|
||||
// 毫秒值转化为秒
|
||||
NSString * times;
|
||||
if ([self is32bit] && [[YYUtility systemVersion] floatValue] <= 10.0) {
|
||||
times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)];
|
||||
}else{
|
||||
times = time;
|
||||
}
|
||||
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times doubleValue]/ 1000.0];
|
||||
NSString* dateString = [formatter stringFromDate:date];
|
||||
return dateString;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+ (NSString *)getDateWithHHMMSS:(NSString *)time {
|
||||
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
|
||||
[formatter setDateStyle:NSDateFormatterMediumStyle];
|
||||
[formatter setTimeStyle:NSDateFormatterShortStyle];
|
||||
[formatter setDateFormat:@"HH:mm:ss"];
|
||||
// 毫秒值转化为秒
|
||||
NSString * times;
|
||||
if ([self is32bit] && [[YYUtility systemVersion] floatValue] <= 10.0) {
|
||||
times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)];
|
||||
}else{
|
||||
times = time;
|
||||
}
|
||||
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times doubleValue]/ 1000.0];
|
||||
NSString* dateString = [formatter stringFromDate:date];
|
||||
return dateString;
|
||||
}
|
||||
|
||||
+ (NSString *)getDateWithTotalTimeWith:(NSString *)time {
|
||||
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
|
||||
formatter.timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
|
||||
[formatter setDateStyle:NSDateFormatterMediumStyle];
|
||||
[formatter setTimeStyle:NSDateFormatterShortStyle];
|
||||
[formatter setDateFormat:@"yyyy.MM.dd HH:mm:ss"];
|
||||
// 毫秒值转化为秒
|
||||
NSString * times;
|
||||
if ([self is32bit] && [[YYUtility systemVersion] floatValue] <= 10.0) {
|
||||
times = [NSString stringWithFormat:@"%f", ([time doubleValue] + 3600 * 1000 * 8)];
|
||||
}else{
|
||||
times = time;
|
||||
}
|
||||
NSDate* date = [NSDate dateWithTimeIntervalSince1970:[times doubleValue]/ 1000.0];
|
||||
NSString* dateString = [formatter stringFromDate:date];
|
||||
return dateString;
|
||||
}
|
||||
|
||||
|
||||
+ (NSString *)getNowTimeTimestampMillisecond{
|
||||
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ;
|
||||
|
||||
[formatter setDateStyle:NSDateFormatterMediumStyle];
|
||||
|
||||
[formatter setTimeStyle:NSDateFormatterShortStyle];
|
||||
|
||||
[formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
|
||||
|
||||
//设置时区,这个对于时间的处理有时很重要
|
||||
|
||||
NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
|
||||
|
||||
[formatter setTimeZone:timeZone];
|
||||
|
||||
NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
|
||||
NSTimeInterval a=[dat timeIntervalSince1970]*1000;
|
||||
NSString * timeSp = [NSString stringWithFormat:@"%.0f", a];
|
||||
|
||||
return timeSp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user