I had some support tickets about dates not showing properly for customers based in the America/Merida timezone.
Essentially America/Merida permanently changed to -0500 (CDT) on October 31, 2021, and it appears that the NSTimeZone does not respect this change, and reports times as -0600 (CST).
Creating a little test tool with the following code:
+(void) run {
NSArray<NSString *> * args = [[NSProcessInfo processInfo] arguments];
if ([args count] > 1) {
NSString *timezone = args[1];
NSLog(@"custom TZ: %@", timezone);
NSTimeZone * tz = [NSTimeZone timeZoneWithName:timezone];
[NSTimeZone setDefaultTimeZone:tz];
}
NSDate * now = [NSDate date];
NSLog(@"Testing Dates: (local timezone : %@)", [NSTimeZone localTimeZone]);
NSLog(@" (default timezone: %@)", [NSTimeZone defaultTimeZone]);
NSLog(@" (is DST : %@)", [[NSTimeZone defaultTimeZone] isDaylightSavingTimeForDate:now] ? @"YES" : @"NO");
NSLog(@" (current cal-tz : %@)", [[NSCalendar currentCalendar] timeZone]);
NSLog(@" (current locale : %@)", [[NSLocale currentLocale] localeIdentifier]);
NSLog(@"Now: %@", now);
}
And running with the America/Merida timezone passed in, I'm getting the following output:
custom TZ: America/Merida
Testing Dates: (local timezone : Local Time Zone (America/New_York (EDT) offset -14400 (Daylight)))
(default timezone: America/Merida (CST) offset -21600)
(is DST : NO)
(current cal-tz : America/Merida (CST) offset -21600)
(current locale : en_US)
Now: Tue May 14 15:06:14 2024
Running the same code on Linux via the GNUStep implementation of Objective-C, I get the correct output with America/Merida showing up as CDT (ie (is DST : YES)).
Are there any good ways to work around this?