Question

The Using Time Zones Guide shows how to check if daylight saving time (DST) is in action for the current date and how to get the next date when daylight saving time changes. With calls to:

isDaylightSavingTime
daylightSavingTimeOffset
nextDaylightSavingTime

E.g.

Bool isDST = [[NSTimeZone systemTimeZone] isDaylightSavingTime];

But I need to find out if a future date is DST or not so that when users scroll to a distant and far off date, they can see my graph plotted with the time axis labelled correctly (GMT or BST).

The problem is that isDayLightSavingTime seems to take two parameters, one passed to it explicitly (NSTimeZone) and the other implicitly, namely the current system time.

Was it helpful?

Solution

You just need to call isDaylightSavingTimeForDate, passing in the relevant NSDate.

It's not that isDaylightSavingTime itself has two parameters - it's that it calls isDaylightSavingTimeForDate with the current date. From the docs for isDaylightSavingTime:

This method invokes isDaylightSavingTimeForDate: with the current date as the argument.

So just skip the "convenience" method and call isDaylightSavingTimeForDate specifying the date you want to check. (I'd give some sample code, but the chances of me getting Objective C syntax correct are very slim...)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top