[Glass] DateAndTime ... all pretty strange

Dale Henrichs via Glass glass at lists.gemtalksystems.com
Fri Jan 13 10:22:54 PST 2017

On 1/11/17 10:32 PM, Marten Feldtmann wrote:
> Well, printString and fromString introduce some kind of a date/time 
> representation. Whatever this is, the output should be useable via the 
> parsing method.
I am not sure what you mean by this ... if the output of printString for 
DateAndTime cannot be used to produce the same object suing #fromString: 
then I think that it is a bug ...

And the results that you were seeing indicates that there was a bug and 
I gave you a patch to try.

Did you try the patch and if you did, I would appreciate it if you let 
me know ... if you don't let me know, I will not publish the patch ...
> If I use printString it looks like ISO8601 and/or RFC3339 - but the 
> corresponding method "fromString" introduces locales and this breaks 
> the whole stuff. And I do not find any "," in the syntax specification 
> of ISO8601 and RFC3339.
I guess I'll see if the ANSI standard description describes which format 
they are using, but your guess is probably right and it is good to know 
that a Locale-specific decimal point is not supposed to be used here.
> Actually I would NOT like to see a locale introduced there. I prefere 
> method with names showing me, that locales are used by that method 
> (e.g asLocaleC) - then one knows, what to expect.
That makes sense ... in this particular case the Locale is  used by the 
printString for ScaledDecimal and the printString code for DateAndTime 
was parsing the printString of the ScaledDecimal expecting a $. instead 
of a Locale-specific decimal point.

Again, I am hoping that you let me know whether or not my proposed patch 
actually fixes the problem.
> And I also do not see a need for that large number of digits in the 
> fractional part of the seconds - as I said it may results in problems 
> with other languages (though it is allowed to have so many digits) and 
> the resolution shown here seems to be not true - there seems to be the 
> natural single precision/double conversion precision problem.
By default, DateAndTime class>>now uses System class>>_timeGmtFloat 
which returns a Float with up to microsecond resolution.

If you use one of the other DateAndTime factory methods:


The object in the second argument will be used to control how many 
decimal points are displayed by the printString method.

If you are content with 1 second resolution you can use 
#printStringWithRoundedSeconds or printRoundedOn:. Or you can override 
DateAndTimeANSI class>>now and/or send #beRounded to the DateAndTime 
instance before using it ...

If you want to have a specific number of decimal points of resolution 
for seconds, then the best bet is to use a ScaledDecimal for seconds by 
adding and using a #beScaledDecimal: and/or override DateAndTimeANSI 

Again, I am hoping that you let me know whether or not my proposed patch 
actually fixes your original problem.


More information about the Glass mailing list