zoukankan      html  css  js  c++  java
  • 判断 第二天 是否到来,

    -(BOOL)nextDayIsComing

    {

        NSUserDefaults *myDefault = [NSUserDefaultsstandardUserDefaults];

        NSDate *beforeDate = [myDefault objectForKey:@"date"];

        if (beforeDate == 0) {

            NSDateComponents *comp = [[NSDateComponentsalloc]init];

            [comp setMonth:07];

            [comp setDay:17];

            [comp setYear:2013];

            NSCalendar *myCal = [[NSCalendaralloc] initWithCalendarIdentifier:NSGregorianCalendar];

            NSDate *myDate = [myCal dateFromComponents:comp];

            beforeDate = myDate;

        }

        

        NSDate *now = [NSDate new];

        unsigned units  = NSMonthCalendarUnit|NSDayCalendarUnit|NSYearCalendarUnit;

        

        NSCalendar *myCal01 = [[NSCalendaralloc] initWithCalendarIdentifier:NSGregorianCalendar];

        NSDateComponents *secondComponent = [myCal01 components:units fromDate:now];

        NSInteger nowDay = [secondComponent day];

        

        NSDateComponents *firstComponent = [myCal01 components:units fromDate:beforeDate];

        NSInteger beforeDay = [firstComponent day];

        

        if (nowDay > beforeDay) {

            [myDefault setObject:now forKey:@"date"];

            return YES;

        }else{

            return YES;

        }

    }

  • 相关阅读:
    Linux rcp命令详解
    Linux patch命令详解
    Linux paste命令详解
    linux od命令详解
    linux mv命令详解
    Linux more命令详解
    Linux mktemp命令
    MySQL状态变量详解
    mysql性能分析show profile/show profiles
    MySQL执行计划
  • 原文地址:https://www.cnblogs.com/guligei/p/3198089.html
Copyright © 2011-2022 走看看