-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我的一点心得,关于时间的 #207
Comments
// #import "TimeModel.h" @implementation TimeModel
-(NSDateFormatter *)dateFormatter{
#pragma clang diagnostic push
} |
调用 |
这个是个UI层,数据处理比如时间我建议单独列出来。
我的:
TimeModel.h
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface TimeModel : NSObject
/*
*/
#pragma mark —— 当前时间:来源iOS系统Api
@Property(nonatomic,strong)NSDate *currentDate;
@Property(nonatomic,strong)NSString *currentTimestampStr;//当前iOS时间戳(字符串格式)
@Property(nonatomic,assign)NSTimeInterval currentTimestampSec;//当前时间戳秒数(基本数据类型)
@Property(nonatomic,assign)NSTimeInterval currentTimestampInterval;// 实际是一个double ; interval得出的数会有6位小数,应该是精确到微秒
@Property(nonatomic,assign)NSInteger currentEra;//当前年代
@Property(nonatomic,assign)NSInteger currentYear;//当前年份
@Property(nonatomic,assign)NSInteger currentMonth;//当前月份
@Property(nonatomic,assign)NSInteger currentDay;//当前日
@Property(nonatomic,assign)NSInteger currentHour;//当前小时
@Property(nonatomic,assign)NSInteger currentMin;//当前分
@Property(nonatomic,assign)NSInteger currentSec;//当前秒
@Property(nonatomic,assign)NSInteger currentNanoSec;//当前纳秒
@Property(nonatomic,assign)NSInteger currentWeekday;//当前星期几 表示周里面的天 1代表周日 2代表周一 7代表周六
@Property(nonatomic,assign)NSInteger currentWeekdayOrdinal;//
@Property(nonatomic,assign)NSInteger currentQuarter;
@Property(nonatomic,assign)NSInteger currentWeekOfMonth;//该月份的第几周
@Property(nonatomic,assign)NSInteger currentWeekOfYear;//该年份的第几周
@Property(nonatomic,assign)NSInteger currentYearForWeekOfYear;//
#pragma mark —— 自定义某一个时间:来源比如说是服务器时间
@Property(nonatomic,strong)NSDate *customDate;
@Property(nonatomic,strong)NSString *customTimestampStr;//自定义某一个时间的时间戳(字符串格式)
@Property(nonatomic,assign)NSTimeInterval customTimestampSec;//自定义某一个时间的时间戳秒数(基本数据类型)
@Property(nonatomic,assign)NSTimeInterval customTimestampInterval;// 实际是一个double ; interval得出的数会有6位小数,应该是精确到微秒
@Property(nonatomic,assign)NSInteger customEra;//当前年代
@Property(nonatomic,assign)NSInteger customYear;//当前年份
@Property(nonatomic,assign)NSInteger customMonth;//当前月份
@Property(nonatomic,assign)NSInteger customDay;//当前日
@Property(nonatomic,assign)NSInteger customHour;//当前小时
@Property(nonatomic,assign)NSInteger customMin;//当前分
@Property(nonatomic,assign)NSInteger customSec;//当前秒
@Property(nonatomic,assign)NSInteger customNanoSec;//当前纳秒
@Property(nonatomic,assign)NSInteger customWeekday;//当前星期几 表示周里面的天 1代表周日 2代表周一 7代表周六
@Property(nonatomic,assign)NSInteger customWeekdayOrdinal;//
@Property(nonatomic,assign)NSInteger customQuarter;
@Property(nonatomic,assign)NSInteger customWeekOfMonth;//该月份的第几周
@Property(nonatomic,assign)NSInteger customWeekOfYear;//该年份的第几周
@Property(nonatomic,assign)NSInteger customYearForWeekOfYear;//
#pragma mark —— 时区
@Property(nonatomic,strong)NSTimeZone *localTimeZone;//手机当前时区
@Property(nonatomic,strong)NSString *customTimeZoneStr;//自定义时区名 默认北京时区
@Property(nonatomic,strong)NSTimeZone *customTimeZone;//自定义时区
#pragma mark —— 时间格式化
@Property(nonatomic,strong)NSString *dateFormatterStr;
@Property(nonatomic,strong)NSDateFormatter *dateFormatter;
#pragma mark —— 结论部分 外层怎么用自己去拼接 内核只做重要工作
//特殊标注:星期是以周日开始的,1代表周日、2代表周一...7代表周六
@Property(nonatomic,assign)NSInteger timeOffset;//当前时区与格林威治时间的时间差
@Property(nonatomic,assign)NSInteger customTimeOffset;//自定义时区与格林威治时间的时间差
-(void)makeSpecificTime;//各个具体时间的拆解
//以当前手机系统时间(包含了时区)为基准,给定一个日期偏移值(正值代表未来,负值代表过去,0代表现在),返回字符串特定格式的“星期几”
+(NSString *)whatDayOfWeekDistanceNow:(NSInteger)offsetDay;
@EnD
NS_ASSUME_NONNULL_END
The text was updated successfully, but these errors were encountered: