Hi sven
I'm confused ft := ZTimestampFormat fromString: '02/11/2017'. ft format: DateAndTime now produces 10/11/1017060986 While I do not want time but just the date. and the date is wrong. So I will do it manually but I found sad that ZTimestampFormat cannot handle just handling days. I could then pass also a date and it would not ask for nanoseconds. Stef |
Hi Stef,
> On 22 Oct 2017, at 17:45, Stephane Ducasse <[hidden email]> wrote: > > Hi sven > > I'm confused > > ft := ZTimestampFormat fromString: '02/11/2017'. > ft format: DateAndTime now > > produces 10/11/1017060986 > > While I do not want time but just the date. > and the date is wrong. > > So I will do it manually but I found sad that ZTimestampFormat cannot > handle just handling days. > I could then pass also a date and it would not ask for nanoseconds. > > Stef ZTimestampFormat works with example based format specifications. This works by making each component unique, using a sequential number. Consult the class comment for a full explanation. The class side's #formatSpecifications lists the tokens that are understood and their meaning. To go back to your issue, The year is the first component, written as 2001, the month the third and the day the second. So you probably want to do: (ZTimestampFormat fromString: '03/02/2001') format: DateAndTime now. => '22/10/2017' HTH, Sven |
Hi sven
I read the class comments in fact :) and now rereading and your answer I start to understand. What the class comments did not convey to me was that you have to follow the 2001 example. The "#reference timestamp" was confusing to me. I could not undersrtand why you where talking about a method (that does not exist in fact). Then I could not understand how the numbering of the component of the example where related to the example you give below. And I can tell you that I browse the class side accessing but I could not find a simple date pattern. By the way using a number higher than 12 for days could help identifying the day from the month. And now I see that as I expected we can also pass a date and not be forced to pass a (ZTimestampFormat fromString: '03/02/2001') format: Date today. If you are interested I can try to propose a better class comment. And BTW I already used the formatter but more than one year ago. Stef On Sun, Oct 22, 2017 at 11:00 PM, Sven Van Caekenberghe <[hidden email]> wrote: > Hi Stef, > >> On 22 Oct 2017, at 17:45, Stephane Ducasse <[hidden email]> wrote: >> >> Hi sven >> >> I'm confused >> >> ft := ZTimestampFormat fromString: '02/11/2017'. >> ft format: DateAndTime now >> >> produces 10/11/1017060986 >> >> While I do not want time but just the date. >> and the date is wrong. >> >> So I will do it manually but I found sad that ZTimestampFormat cannot >> handle just handling days. >> I could then pass also a date and it would not ask for nanoseconds. >> >> Stef > > ZTimestampFormat works with example based format specifications. This works by making each component unique, using a sequential number. Consult the class comment for a full explanation. The class side's #formatSpecifications lists the tokens that are understood and their meaning. > > To go back to your issue, The year is the first component, written as 2001, the month the third and the day the second. So you probably want to do: > > (ZTimestampFormat fromString: '03/02/2001') format: DateAndTime now. > > => '22/10/2017' > > HTH, > > Sven > > > |
Free forum by Nabble | Edit this page |