[bug] "DateTime printOn:" output cannot be parsed with "DateTime readFrom:"

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

[bug] "DateTime printOn:" output cannot be parsed with "DateTime readFrom:"

Nikita Kalinin
Issue status update for
http://smalltalk.gnu.org/node/864
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/864

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  nixo
 Updated by:   nixo
 Status:       active

Unlike Date, Time, Duration the DateTime instance cannot be initialized
with a string which is generated by DateTime itself.



st> DateTime now
 2014-08-24T17:50:20+04:00
st> DateTime readFrom: stdin
 2014-08-24T17:50:20+04:00
 2014-10-13T20:04:00+00:00

The DateTime prints itself as YYYY-MM-DD + 'T' + HH:MM:SS +
[(+|-)HH:MM[:SS]] (or [Date]T[Time][+-Offset]) and these format
hardcoded. However readFrom: expects [Date] [Duration]. An offset should
be set with offset: aDuration messsage.



st> dt := DateTime readFrom: stdin
2014-08-24 00:17:50:20
 2014-08-24T17:50:20+00:00
st> dt offset: (Duration days: 0 hours: 4 minutes: 0 seconds: 0)
 2014-08-24T17:50:20+04:00

So there is now way to read/write date and time simultaneously.



_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] "DateTime printOn:" output cannot be parsed with "DateTime readFrom:"

Holger Freyther
On Sun, Aug 24, 2014 at 07:40:59AM -0700, Nikita Kalinin wrote:

Hi!

> Unlike Date, Time, Duration the DateTime instance cannot be initialized
> with a string which is generated by DateTime itself.

> So there is now way to read/write date and time simultaneously.

what do you propose? The >>#displayString is meant to show a represntation
of an object. I think there is no contract that it can be parsed. The
question is what you want to achieve and if following one of the ISO
dates wouldn't be a better approach?

holger

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk