DateUtility
/* 2つのNSDate型変数が同じ日付であるかのチェック */
// 同じ日付か?YES:同じ日付 NO:違う
// oneDate 比較対象の日付1
// otherDate 比較対象の日付2
+ (BOOL)isEqualDate:(NSDate *)oneDate otherDate:(NSDate *)otherDate{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
dateFormatter.dateFormat = @"yyyy/MM/dd";
NSString *oneDateStr = [dateFormatter stringFromDate:oneDate];
NSString *otherDateStr = [dateFormatter stringFromDate:otherDate];
return [oneDateStr isEqualToString:otherDateStr];
}
/* 現地時間の取得 */
+ (NSDate *)getLocaleDate{
NSDate *tmpDate = [NSDate date];
NSTimeZone *timeZone = [NSTimeZone systemTimeZone];
NSInteger seconds = [timeZone secondsFromGMTForDate:tmpDate];
NSDate *localDate = [tmpDate dateByAddingTimeInterval:seconds];
return localDate;
}
/* Unix時間からのNSDateの取得 */
// Unix時間をミリ秒を変換する場合
+ (NSDate *)dateFromUnixTimeMilisecond:(unsigned long long)unixTime{
NSInteger miliSeconds = 1000;
unsigned long long unixTimeSecond = unixTime / miliSeconds;
NSDate *dateFromUnixTime = [NSDate dateWithTimeIntervalSince1970:unixTimeSecond];
return dateFromUnixTime;
}