discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDateFormatter issue


From: Niels Grewe
Subject: Re: NSDateFormatter issue
Date: Mon, 13 Mar 2017 18:26:52 +0000

Hi David,

just a small pointer wrt this: I vaguely recall having seen a similar phenomenon in the past, where it turned out that our NSDateFormatter implementation was sensitive to the order in which you called the setters. I was under the impression that that problem had been fixed -- but maybe there's a bug still hiding in there...

Cheers,

Niels

Von: dlobron@akamai.com
Gesendet: 13. März 2017 4:33 nachm.
An: discuss-gnustep@gnu.org
Betreff: NSDateFormatter issue

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



_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

reply via email to

[Prev in Thread] Current Thread [Next in Thread]