|
From: | Stefan Bidigaray |
Subject: | Re: NSDateFormatter SetDateStyle / setTimeStyle not working |
Date: | Sat, 26 Aug 2017 11:36:57 -0400 |
Hmm, that does seem stage. It should all be working. I'm sure the problem is not the FreeBSD source, David does a pretty good job keeping those updated.I'll test it on my end a bit to try to figure it out.On Aug 26, 2017 00:46, "Edwin Ancaer" <eancaer@gmail.com> wrote:[format setLenient: NO] and [format setLenient: YES].Fred, Stefan,Indeed, the instruction [format lenient] returns 1, independant of setting the value with
I'm sure I saw libicu mentioned in the dependencies for gnustep, and given the definition of isLenient in NSDatformatter.m and the fact that I got 1 from isLenient, I supposed that GS_USE_ICU was 1: return NO resulting in the value 1 seems illogical.
- (BOOL) isLenient
{
#if GS_USE_ICU == 1
return (BOOL)udat_isLenient (internal->_formatter);
#else
return NO; }
#endif But thinking of it, this is the source from https://github.com/gnustep/libs-base/blob/master/Source/NSDa ., I've got no idea were FreeBSD is getting its sources. I will have to look into the freebsd ports mechanism to find out, just to be sure. Or try the debugger, to see what is really going on.teFormatter.m Concerning the locale, the value for systemlocale is "en_US_posix", the default locale is "nl_BE",and the locale returned from the NSDateFormatter is also "nl_BE". But I admit, the returned values do not look correctly formatted either.Again, maybe the debugger is the best way to find out what is going wrong.Thanks for your anwers already, I'll see if I can find out more about this. Or give up, and just use format strings....Kind regards,Edwin2017-08-25 15:21 GMT+02:00 Stefan Bidigaray <stefanbidi@gmail.com>:Based on your previous posts, it sounds like your current locale is en_US_POSIX. Can you verify that by checking the output of [NSDateFormatter -locale]? This locale outputs the same date string regardless of the style.You can set the formatter's locale with -setLocale: before any calls to -stringFromDate:.On Aug 25, 2017 00:38, "Edwin Ancaer" <eancaer@gmail.com> wrote:______________________________Hello,I hardly dare to suggest it, but I have got the impression that the methods setDateStyle & setTimeStyle have no influence on the result of the method stringFromDate, as you can see in the examples below.
Is it me, again not having understood the workings of these classes completely, or is there really a problem?I'm on FreeBSD 11.0, with gnustep installed from the ports.Examples:
NSDate* d = [NSDate date];
NSLog(@"the date as date object %@", d);
2017-08-25 06:20:32.673 TM1[1295:100101] the date as date object 2017-08-25 06:20:32 +0200
NSDateFormatter* format = [[NSDateFormatter alloc] init];
NSLog(@"Dateformatter defaults");
NSLog(@" DateFormatter timezone: %@", [format timeZone]);
NSLog(@" DateFormatter locale: %@", [format locale]);
NSLog(@" DateFormatter datestyle: %u", [format dateStyle]);
NSLog(@" DateFormatter timestyle: %u", [format timeStyle]);
NSLog(@" Date formatted with defaults %@", [format stringFromDate: d]);
2017-08-25 06:20:32.695 TM1[1295:100101] Dateformatter defaults
2017-08-25 06:20:32.703 TM1[1295:100101] DateFormatter timezone: Europe/Brussels
2017-08-25 06:20:32.711 TM1[1295:100101] DateFormatter locale: nl_BE
2017-08-25 06:20:32.719 TM1[1295:100101] DateFormatter datestyle: 0
2017-08-25 06:20:32.727 TM1[1295:100101] DateFormatter timestyle: 0
2017-08-25 06:20:32.736 TM1[1295:100101] Date formatted with defaults 20170825 06:20 a.m.
[format setDateStyle: NSDateFormatterNoStyle];
[format setTimeStyle: NSDateFormatterMediumStyle];
NSLog(@"DateFormatter: Date -> NoStyle, Time -> MediumStyle");
NSLog(@" DateFormatter timezone: %@", [format timeZone]);
NSLog(@" DateFormatter locale: %@", [format locale]);
NSLog(@" DateFormatter datestyle: %u", [format dateStyle]);
NSLog(@" DateFormatter timestyle: %u", [format timeStyle]);
NSLog(@" Date formatted with style %@", [format stringFromDate: d]);
2017-08-25 06:20:32.745 TM1[1295:100101] DateFormatter: Date -> NoStyle, Time -> MediumStyle
2017-08-25 06:20:32.754 TM1[1295:100101] DateFormatter timezone: Europe/Brussels
2017-08-25 06:20:32.763 TM1[1295:100101] DateFormatter locale: nl_BE
2017-08-25 06:20:32.773 TM1[1295:100101] DateFormatter datestyle: 0
2017-08-25 06:20:32.783 TM1[1295:100101] DateFormatter timestyle: 2
2017-08-25 06:20:32.794 TM1[1295:100101] Date formatted with style 20170825 06:20 a.m.
[format setDateStyle: NSDateFormatterLongStyle];
[format setTimeStyle: NSDateFormatterLongStyle];
NSLog(@"DateFormatter: Date -> LongStyle, Time -> LongStyle");
NSLog(@" DateFormatter timezone: %@", [format timeZone]);
NSLog(@" DateFormatter locale: %@", [format locale]);
NSLog(@" DateFormatter datestyle: %u", [format dateStyle]);
NSLog(@" DateFormatter timestyle: %u", [format timeStyle]);
NSLog(@" Date formatted with style %@", [format stringFromDate: d]);
2017-08-25 06:20:32.809 TM1[1295:100101] DateFormatter: Date -> LongStyle, Time -> LongdiumStyle
2017-08-25 06:20:32.825 TM1[1295:100101] DateFormatter timezone: Europe/Brussels
2017-08-25 06:20:32.838 TM1[1295:100101] DateFormatter locale: nl_BE
2017-08-25 06:20:32.853 TM1[1295:100101] DateFormatter datestyle: 3
2017-08-25 06:20:32.867 TM1[1295:100101] DateFormatter timestyle: 3
2017-08-25 06:20:32.881 TM1[1295:100101] Date formatted with style 20170825 06:20 a.m.Could someone tell me what the problem is here?Thanks,Edwin Ancaer_________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep
test_nsdateformatter.m
Description: Text Data
[Prev in Thread] | Current Thread | [Next in Thread] |