[squeak-dev] Re: Time now print24

Eliot Miranda eliot.miranda at gmail.com
Fri Jul 8 05:49:10 UTC 2016


Hi All,

> On Jul 7, 2016, at 9:33 AM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 
> Hi All,
> 
>     how does one produce a nice timestamp, simply date and time as in
> 
>     7/7/2016 09:19:38
> 
> Trivial, right?
> 
> So
> 
>     Date today mmddyyyy, ' ', Time now print24 '7/7/2016 09:22:40.914'
> 
> .914, ah, nanos.  How useful.  Let's get rid of them.  No nanos: accessor so
> 
>     Date today mmddyyyy, ' ', (Time now nanos: 0) print24 => MNU
> 
> but there's a seconds accessor, so
> 
>     Date today mmddyyyy, ' ', (Time now seconds: Time now seconds; print24) '7/7/2016 00:00:41
> 
> ??  So seconds: is private, and isn't the dual of Time seconds:
> 
> Time seconds
> 	^ self second
> Time second
> 	^ self asDuration seconds
> Duration seconds
> 	"Answer the number of seconds the receiver represents."
> 	^seconds rem: SecondsInMinute
> 
> Looks broken to me.

Let me be more explicit, and ask for permission to fix this.  One basic bug is the asymmetry between seconds, an accessor that answers seconds mod 60, and seconds: that doesn't set seconds mod 60.  But seconds: is private and could be replaced by eg setTotalSeconds:, presumably without breaking clients, allowing seconds: to be redefined to do the right thing.

I note that the historic bug of changing the semantics of Time now to answer something with finer resolution than one second could have been avoided by adding eg exactlyNow or preciselyNow.

The problem with nanos (apart from the horrible abbreviation) is that it presumes a maximum precision that isn't well chosen.  Microseconds work out much better.  And I hope we change the internal representation accordingly.  But there needs to be done accessor that rounds to the nearest second without revealing the internal precision.  Time now toTheNearestSecond or Time theNearestSecondNow or...?

> 
> Personally I think print24 should not print sub seconds.
> 
> cc'ing to Pharo because I want this timestamp to be the same in both dialects for a profiling tool we want to use in both dialects.
> _,,,^..^,,,_
> best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160707/9c4181cb/attachment.htm


More information about the Squeak-dev mailing list