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;

        }

    }

  • 相关阅读:
    C# String.Format格式说明
    jQuery.json.js
    禁止别人使用"另存为"保存你的网页
    组合问题的递归算法
    jQuery,contents()
    C#string,StringBuilder和Regex类的讲解
    jQuery性能优化指南
    加密算法的C#实现
    m,n组合算法
    jQuery插件—获取URL参数
  • 原文地址:https://www.cnblogs.com/guligei/p/3198089.html
Copyright © 2011-2022 走看看