Jeff,

I can't comment on the problem per se, as I am not a frequent Pharo user.

But whenever something would be all over the place, I'd suggest thinking about wrapping the problem into its own class, so that your point in time is not an instance of DateAndTime but one of your wrapper class. This wrapper could be a subclass (I wouldn't recommend that) or some kind of facade for a DateAndTime specialized for your needs. You can then implement the droppoing of Nanos and whatever else may be needed for your SQLite handling in this specialized class and therefor avoid forgetting to do this on one of the many places in your application.

Just an idea to get a handle on your problem, maybe not worth much more than a few cents.

Joachim


Am 15.06.20 um 06:44 schrieb Jeff Gray:
Hi all.
In Playground I write these lines:

Transcript cr; show: DateAndTime now printString.
Transcript cr; show: (DateAndTime fromSeconds: (DateAndTime now asSeconds))
printString.

and in the Transcript window I get these results:

2020-06-15T14:33:06.630367+10:00
2020-06-15T14:33:06+10:00

I was expecting these two to be the same.

I was hoping to use DateAndTime fromSeconds: and aDateAndTime asSeconds to
convert a DateAndTime to/from a number in order to store it in SQLite, but I
don't like the way the nanos are dropped using this method.
It's all good if I remember to call DateAndTime now truncated, and drop the
nanos myself, but that might be all over the place in my application.

Instead, is there a better way to convert a DateAndTime to and from a
number?



--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



--
-----------------------------------------------------------------------
Objektfabrik Joachim Tuchel          mailto:jtuc...@objektfabrik.de
Fliederweg 1                         http://www.objektfabrik.de
D-71640 Ludwigsburg                  http://joachimtuchel.wordpress.com
Telefon: +49 7141 56 10 86 0         Fax: +49 7141 56 10 86 1



Reply via email to