Question

I've got Time Zone: Central European Summer Time in OS X (automatically based on location). When running my code on simulator I'm getting these results:

NSTimeZone *tz = [NSTimeZone localTimeZone]; // Gives me Local Time Zone (Europe/Warsaw (CEST) offset 7200 (Daylight))

NSString *tzString = [tz localizedName:NSTimeZoneNameStyleShortStandard
                                locale:[NSLocale currentLocale]]; // Gives me CET

Same with EDT / EST - when I set current time as EDT in System -> Preferences then appropriate methods return EST..

Am I missing something?

Was it helpful?

Solution

The Standard in NSTimeZoneNameStyleShortStandard specifically means the non-DST name for the time zone.

If you want to use the DST name or not depending on DST status as of some date, you'd probably have to use -isDaylightSavingTimeForDate: to decide on NSTimeZoneNameStyleShortStandard versus NSTimeZoneNameStyleShortDaylightSaving.

OTHER TIPS

Apple warns of the use of the abbrevations for timezones. Better use the known offset to compute with +timeZoneForSecondsFromGMT:

Use the property -daylightSavingTimeto check day light saving status.

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