Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

isDaylightSavingTime returns NO although my time zone does observe DST

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?

like image 525
Vishal Avatar asked Mar 22 '23 02:03

Vishal


1 Answers

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.

like image 198
matt Avatar answered Apr 05 '23 23:04

matt