Speed difference HFS and NTFS for data
76
It does not really matter. See here for more on the subject (though not a lot more).
Related videos on Youtube
Author by
oxigen
Updated on September 18, 2022Comments
-
oxigen over 1 year
I need to get date for the first day of the week from any date. This code works fine, but for some dates I get a very strange result. A date from the first week of the year converts to last week's date:
NSTimeInterval ti = 1420311299; NSDate* date = [NSDate dateWithTimeIntervalSince1970:ti]; NSLog(@"%@", date); // OUTPUT: 2015-01-03 18:54:59 +0000 NSCalendar* calendar = [NSCalendar currentCalendar]; NSDateComponents *cmps = [calendar components:(kCFCalendarUnitWeekOfYear | kCFCalendarUnitYear) fromDate:date]; cmps.weekday = calendar.firstWeekday; NSLog(@"%@", cmps); // OUTPUT: Calendar Year: 2015 // Week of Year: 1 // Weekday: 1 NSDate* newDate = [calendar dateFromComponents:cmps]; NSLog(@"%@", newDate); // OUTPUT: 2015-12-26 22:00:00 +0000
-
soandos almost 13 yearsRemove the second to last line unless you want the question to get closed.
-
-
oxigen almost 9 yearsThanks. I'll try it. About 2-nd part. As you can see in my example, 3rd of January is a part of 53 week of CURRENT 2015 year. And I can't understand, how is it possible...
-
vikingosegundo almost 9 yearsIt sounds strange, but this is expected behavior. Even Apple steps into this issue twice: alarms not going off the first few days of a year.