NSDate比较
来源:互联网 发布:校园网网络波动大 编辑:程序博客网 时间:2024/06/13 00:10
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSDate * oldDate = [uidSCDictNew objectForKey:userIDForBlogNew];
NSDate * newDate = [NSDate date];
NSCalendar *newcalendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSCalendar *oldcalendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *newcomps = [[[NSDateComponents alloc] init] autorelease];
NSDateComponents *oldcomps = [[[NSDateComponents alloc] init] autorelease];
NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
newcomps = [newcalendar components:unitFlags fromDate:newDate];
oldcomps = [oldcalendar components:unitFlags fromDate:oldDate];
int newyear=[newcomps year];
int newmonth = [newcomps month];
int newday = [newcomps day];
int oldyear=[oldcomps year];
int oldmonth = [oldcomps month];
int oldday = [oldcomps day];
BOOL bsameDay = YES;
if (newyear > oldyear)
{
bsameDay = NO;
}
else
{
if (newmonth > oldmonth)
{
bsameDay = NO;
}
else
{
if (newday > oldday)
{
bsameDay = NO;
}
else
{
bsameDay = YES;
}
}
}
//时间比较,非同一天
if (!bsameDay)
{
//
}
else//同一天
{
}
[pool release];
NSDate * oldDate = [uidSCDictNew objectForKey:userIDForBlogNew];
NSDate * newDate = [NSDate date];
NSCalendar *newcalendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSCalendar *oldcalendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *newcomps = [[[NSDateComponents alloc] init] autorelease];
NSDateComponents *oldcomps = [[[NSDateComponents alloc] init] autorelease];
NSInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
newcomps = [newcalendar components:unitFlags fromDate:newDate];
oldcomps = [oldcalendar components:unitFlags fromDate:oldDate];
int newyear=[newcomps year];
int newmonth = [newcomps month];
int newday = [newcomps day];
int oldyear=[oldcomps year];
int oldmonth = [oldcomps month];
int oldday = [oldcomps day];
BOOL bsameDay = YES;
if (newyear > oldyear)
{
bsameDay = NO;
}
else
{
if (newmonth > oldmonth)
{
bsameDay = NO;
}
else
{
if (newday > oldday)
{
bsameDay = NO;
}
else
{
bsameDay = YES;
}
}
}
//时间比较,非同一天
if (!bsameDay)
{
//
}
else//同一天
{
}
[pool release];
- NSDate比较
- NSDate比较
- NSDate比较
- NSDate (nsdate) 时间 (time )比较
- (NSDate) 时间 (time )比较
- NSDate 时间比较
- NSDate日期比较
- NSDate 时间比较
- NSDate简单转换及比较
- NSString与NSDate互相转换及NSDate比较
- NSString与NSDate互相转换及NSDate比较
- NSString与NSDate互相转换及NSDate比较
- iOS NSDate比较两个时间的大小
- NSDate 当前时间获取和时间比较
- iOS NSDate比较返回差多少时间
- NSDate
- NSDate
- NSDate
- 歪写数学史
- Oracle 中使用 fetch bulk collect into 批量效率的读取游标数据
- LINK:fatal error LNK1104: cannot open file“***.lib”
- Oracle三种集合数据类型(索引表,嵌套表,VARRAY 数组)的比较-PLSQL—之三
- Android帧缓冲区(Frame Buffer)硬件抽象层(HAL)模块Gralloc的实现原理分析
- NSDate比较
- 关于onMeasure()方法和onLayout()方法感悟
- PL/SQL表(oracle内存表)---table()函数用法
- AIS解析工具
- 微软 Entity Framework 实体框架工具 - LINQPad,LINQ交互式数据库查询工具
- Socket 通信(Linux)
- DXperience Winforms12.2版的中文使用手册
- 自然语言也支持泛型
- 我在互联网创业失败的启思录(十四) –--敢梦想,敢追寻