0

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???

ragnarok
  • 75
  • 1
  • 7

1 Answers1

1

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

Arek Holko
  • 8,966
  • 4
  • 28
  • 46
  • i'm rotfl about this. i was trying a lot of different options to make it change. but in the end was correct output. – ragnarok Oct 04 '13 at 15:06
  • Sure, I'm from a country that uses 24-hour system and sometimes have troubles with this too :) – Arek Holko Oct 04 '13 at 15:08
  • I can't stop laughing... It's so funny! – ragnarok Oct 04 '13 at 15:10
  • 1
    If you want to be linguistically correct, 12pm doesn't exist. Nor does 12am. The second between 11:59:59am and 12:00:01pm is "meridian", and the other 12:00:00 is "midnight". But, by convention in the US, noon is called 12:00pm and midnight is called 12:00am. – Hot Licks Oct 04 '13 at 15:25
  • ("Meridian" refers to the sun being directly overhead -- at its highest elevation for the day.) – Hot Licks Oct 04 '13 at 15:33