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;

        }

    }

  • 相关阅读:
    JAVA设计模式之单例模式
    JAVA设计模式之建造模式
    JAVA设计模式之原型模式
    JAVA设计模式之适配器模式
    JAVA设计模式之合成模式
    JAVA设计模式之享元模式
    JAVA设计模式之门面模式
    JAVA设计模式之桥梁模式
    JAVA设计模式之不变模式
    JAVA设计模式之模版方法模式
  • 原文地址:https://www.cnblogs.com/guligei/p/3198089.html
Copyright © 2011-2022 走看看