Hi Sean, On 03 Sep 2014, at 00:32, Sean P. DeNigris <[email protected]> wrote:
> Sven Van Caekenberghe-2 wrote >> Maybe you got the example and the input mixed up ? > > Oh yeah, I did, but even the example in that case is ambiguous, no? > > (ZTimestampFormat fromString: '02/03/01 (16:05:06)') > parse: '10/10/10 (12:01:01)'. > > How does it decide whether it's American i.e. Feb 3rd, or European i.e. Mar > 2nd? No, it is not ambiguous. The positions in the pattern are not used to determine the meaning of the elements, only the values. For example, limited to date elements only: (ZTimestampFormat fromString: '02/03/01') format: Date today. => '09/03/14' (ZTimestampFormat fromString: '03/02/01') format: Date today. => '03/09/14' (ZTimestampFormat fromString: 'Feb 3, 2001') format: Date today. => 'Sep 3, 2014' (ZTimestampFormat fromString: '02-FEB-2001') format: Date today. => '09-SEP-2014' (ZTimestampFormat fromString: 'Saturday, Februari 3 ''01') format: Date today. => 'Wednesday, September 3 ''14' The reference date is 20010203 which was a Saturday, the recognised elements for dates are: '2001' yearFourDigits '01' yearTwoDigits '02001' yearFull '02' monthTwoDigits '2' month 'February' monthNameCapitalized 'february' monthNameLowercased 'FEBRUARY' monthNameUppercased 'Feb' monthNameAbbreviatedCapitalized 'feb' monthNameAbbreviatedLowercased 'FEB' monthNameAbbreviatedUppercased '3' day '_3' dayTwoDigitsSpacePadded '03' dayTwoDigits See #formatSpecifications, each of those has parse and format methods, like #format:yearTwoDigitsOn: and #parseYearTwoDigitsFrom: Sven
