Reading a timestamp from a stream

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Reading a timestamp from a stream

cdavidshaffer
In vw7.9 I'm looking for the inverse of:

Locale current
        printAsTime: Timestamp now policyNamed: #iso8601

The sample code in the Internationalization Guide (pdf in docs) only shows:

Locale current readTimestampFrom: ...

but this seems to ignore the format of that timestamp.  That is, if I give it an iso8601 formatted timestamp:

Locale current readTimestampFrom:  '2012-08-13T09:32:00-04:00' readStream

I get a walkback (Illegal month) which is to be expected as there seems to be no way to tell the locale which format I want to use for reading.  I did manage to figure out:

|r|
r := TimestampReader newFor: #en_US customFormatString: '%4y-%2b-%2dT%2h:%2m:%2s%5r;%4y-%2b-%2d;%2h:%2m:%2s;'.
r readTimestampFrom: ('2012-08-13T09:32:00-04:00') readStream

but this seems like a workaround for a deficiency in the TimestampReader API (that you can't tell it which policy you want it to use).  Has anyone at Cincom looked at TimestampReader lately and especially TimestampReader>>readLocaleDataOfTime:for:?  I think it deserves a red flag of some kind.  The documentation could also use a lot of work too.  It took me an hour to figure out this workaround.  Still rather be using VW than anything else though ;-)

David


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Reading a timestamp from a stream

Kooyman, Les
The points that have been raised here are in the process of being addressed.
 
An additional format has been introduced called #custom which can be used to create a use-specific (even transient) policy that can be used both for reading and writing. It was originally created based on an internal request from our team, so it was documented by word of mouth.
 
There are also additional iso-8601 methods that suit slightly different use cases for reading that will also be introduced during the 7.10 cycle.
 
The Internationalization Guide is under revision since several things such as this have not been documented. (This is solely my fault, and not the fault of our fine tech writers who can only write when they have material to work with.)


From: David Shaffer
Sent: Sat 8/18/2012 10:21 PM
To: [hidden email]
Subject: [vwnc] Reading a timestamp from a stream

In vw7.9 I'm looking for the inverse of:

Locale current
	printAsTime: Timestamp now policyNamed: #iso8601

The sample code in the Internationalization Guide (pdf in docs) only shows:

Locale current readTimestampFrom: ...

but this seems to ignore the format of that timestamp.  That is, if I give it an iso8601 formatted timestamp:

Locale current readTimestampFrom:  '2012-08-13T09:32:00-04:00' readStream

I get a walkback (Illegal month) which is to be expected as there seems to be no way to tell the locale which format I want to use for reading.  I did manage to figure out:

|r|
r := TimestampReader newFor: #en_US customFormatString: '%4y-%2b-%2dT%2h:%2m:%2s%5r;%4y-%2b-%2d;%2h:%2m:%2s;'.
r readTimestampFrom: ('2012-08-13T09:32:00-04:00') readStream

but this seems like a workaround for a deficiency in the TimestampReader API (that you can't tell it which policy you want it to use).  Has anyone at Cincom looked at TimestampReader lately and especially TimestampReader>>readLocaleDataOfTime:for:?  I think it deserves a red flag of some kind.  The documentation could also use a lot of work too.  It took me an hour to figure out this workaround.  Still rather be using VW than anything else though ;-)

David


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc