问题
I'd like to get raw offset from GMT. I know the answer could be like that:
NSTimeZone *zone = [NSTimeZone timeZoneWithName:@"Europe/Berlin"];
NSInteger *offset = [zone secondsFromGMT];
(like here: iOS - How to get raw offset for timezone?)
But the problem is, it doesn't give me raw offset (for Berlin +1), but only offset with DST (+2), that is, for the current date.
回答1:
NSTimeZone
has a property daylightSavingTimeOffset
which returns the difference to the raw offset
NSTimeZone *zone = [NSTimeZone timeZoneWithName:@"Europe/Berlin"];
NSTimeInterval rawOffset = [zone secondsFromGMT] - [zone daylightSavingTimeOffset];
来源:https://stackoverflow.com/questions/31987925/objective-c-how-to-get-raw-offset-without-dst-using-nstimezone