Question

I was simply playing around with timers and i found this:

 - (void)viewDidLoad{
     [super viewDidLoad];
     NSDate *date = [NSDate date];
     dFormatter = [[NSDateFormatter alloc] init]; //instance variable

     NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

     unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit;
     NSDateComponents *dateC = [calendar components:unitFlags fromDate:date];
     [dateC setSecond:1];
     [dateC setHour:0];
     [dateC setMinute:0];

     NSDate *fireDate = [calendar dateFromComponents:dateC];
     [dFormatter setTimeStyle:NSDateFormatterLongStyle];
     [dFormatter setDateStyle:NSDateFormatterMediumStyle];
     NSLog(@"%@", [dFormatter stringFromDate:fireDate]);
 }

The output is amazingly : Oct, 4 12:00:01 AM

I'm trying to set up a timer-fire-date that starts some hours in the past.

Should i report this, or is there a way to make that date become something like oct, 4 00:00:01 AM???

Était-ce utile?

La solution

12:00:01 AM is equal to 1 second after midnight. Or am I missing something here?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top