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" <[email protected]> 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
> [email protected]
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep
>
>
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to