4

Checking -[NSTimeZone isDaylightSavingTime] is giving me NO, and I don't know why. On my system I have the correct time displayed, and my time zone is Eastern US -- New York, which observes DST.

NSTimeZone *sZone = [NSTimeZone systemTimeZone];
BOOL isDST = [sZone isDaylightSavingTime];
if (isDST) 
    NSLog(@"\n Daylight saving");
else
    NSLog(@"\n Not in Daylight saving");    // This prints

Can anyone please explain why this would be happening, and a possible remedy?

jscs
  • 63,694
  • 13
  • 151
  • 195
Vishal
  • 279
  • 3
  • 8
  • 18
  • http://stackoverflow.com/questions/8440058/how-do-you-return-the-system-time-zone-as-a-string – El Tomato Jan 07 '14 at 03:36
  • That is not your real code. Please paste in your real code. – matt Jan 07 '14 at 03:43
  • 1
    Why do you expect `isDayLightSavingTime` to return `YES` today? – rmaddy Jan 07 '14 at 03:48
  • Yes, I realized that after Matt answered it.. may be I was thinking too much earlier, however I gained info that isDaylightSavingTime is date-based on current date. – Vishal Jan 07 '14 at 04:47

1 Answers1

7

isDaylightSavingTime is date-based; the answer depends on the current date. Today is January 6, and on January 6 in your time zone, daylight saving time is not in use. Thus, the result you are seeing is correct.

matt
  • 515,959
  • 87
  • 875
  • 1,141