[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSDateFormatter issue
From: |
Lobron, David |
Subject: |
NSDateFormatter issue |
Date: |
Mon, 13 Mar 2017 15:32:51 +0000 |
Hi All,
I've been working to get the NSDateFormatter class working with my company's
GNUStep version, which is based on GNUStep-1.24.8 for GNU/Linux. I updated my
build flags to signal that libicu should be used, and I verified with print
statements that NSDateFormatter's GS_USE_ICU variable is set to true.
However, when I try to format an NSDate object, I'm finding that although the
date is correct, the format never changes. My test code looks like this:
NSDateFormatter *dateFormatter = [[NSDateFormatter new] autorelease];
dateFormatter.dateStyle = NSDateFormatterMediumStyle;
dateFormatter.timeStyle = NSDateFormatterMediumStyle;
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"GMT"]];
NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:118800];
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSString *dateStr = [dateFormatter stringFromDate:date];
NSString *refStr = @"Jan 2, 2001, 9:00:00 AM";
NSLog(@"dateStr = %@, refStr = %@", dateStr, refStr);
But it prints the following:
dateStr = 20010102 09:00 AM, refStr = Jan 2, 2001, 9:00:00 AM
On a Mac, by contrast, dateStr has the correct format:
2017-03-13 11:30:03.081 testNsDateFormatter[6357:607704] dateStr = Jan 2, 2001,
9:00:00 AM, refStr = Jan 2, 2001, 9:00:00 AM
Does anyone know what might be causing this? If not, I will dig deeper into
NSDateFormatter and also check libicu. I tend to think libicu is not the
problem, because it runs a lot of internal tests on the udat_format function,
which is what NSDateFormatter is calling, and I've confirmed that the format
tests pass when run within libicu.
Thanks,
David