Printing nanos in Time print24

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

Printing nanos in Time print24

Stephan Eggermont-3
Since 2009-6-25 (dtl)
Time>>#print24:showSeconds:on:
prints nanos. This contradicts the class and
method comments. The tests carefully
avoid the issue.

Why was this behavior introduced,
and can it safely be improved?
It occurs in both Squeak and Pharo (issue 14198)

Stephan

Reply | Threaded
Open this post in threaded view
|

Re: Printing nanos in Time print24

Stephan Eggermont-3
Anyone?

Reply | Threaded
Open this post in threaded view
|

Re: Printing nanos in Time print24

carlo.t
Maybe take a look at Issue 2350 in pharo (https://pharo.fogbugz.com/f/cases/2398/Duration-parsing-nanos)
Reply | Threaded
Open this post in threaded view
|

Re: Printing nanos in Time print24

David T. Lewis
In reply to this post by Stephan Eggermont-3
On Thu, Oct 09, 2014 at 12:30:30PM +0200, Stephan Eggermont wrote:
> Since 2009-6-25 (dtl)
> Time>>#print24:showSeconds:on:
> prints nanos. This contradicts the class and
> method comments. The tests carefully
> avoid the issue.
>
> Why was this behavior introduced,
> and can it safely be improved?
> It occurs in both Squeak and Pharo (issue 14198)

Stephan,

I do not know the reason, but I see that the method has my initials on
it, so I owe you a better answer.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Printing nanos in Time print24

David T. Lewis
On Mon, Oct 13, 2014 at 11:07:18PM -0400, David T. Lewis wrote:

> On Thu, Oct 09, 2014 at 12:30:30PM +0200, Stephan Eggermont wrote:
> > Since 2009-6-25 (dtl)
> > Time>>#print24:showSeconds:on:
> > prints nanos. This contradicts the class and
> > method comments. The tests carefully
> > avoid the issue.
> >
> > Why was this behavior introduced,
> > and can it safely be improved?
> > It occurs in both Squeak and Pharo (issue 14198)
>
> Stephan,
>
> I do not know the reason, but I see that the method has my initials on
> it, so I owe you a better answer.
>

The change was introduced here:

  Name: Kernel-dtl.177
  Author: dtl
  Time: 13 July 2009, 12:08:49.002 pm
  UUID: 152a8933-6259-46cc-a118-55029e8dbb5a
  Ancestors: Kernel-dtl.176
 
  Reference Mantis 0007356: DateAndTime fromSeconds: 0.5 => walkback, broken
  since Mantis 4669
 
  Allow #fromSeconds: to accept non-integer arguments, and update Time>>printString
  to display fractional seconds for better compatibility with the original Squeak
  implementation. The expressions 'DateAndTime fromSeconds: 0.5' and 'Time
  fromSeconds: 0.5' now behave as expected.
 
  This change set fixes a limitation of #fromSeconds: that was introduced in
  Mantis 4669: [ENH] TimeForSpeed. It changes the corresponding #fromSeconds:
  and #printString for class Time to match DateAndTime and to be more compatible
  with the original Squeak implementation.

Based on this, I think that my intention at the time was to make Time>>printString
behave similarly to its original intended behavior. I am not sure if the problem
with Time>>print24:showSeconds:on: is a bug in the method comment or in its
current implementation.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Printing nanos in Time print24

Stephan Eggermont-3
In reply to this post by Stephan Eggermont-3
Ok, that is clear. I also have a need for time printing to seconds precision.
Would it be better to keep the current behavior, fix the comments and
add a method hhmmss or so, or to route printString to a printWithNanos
and remove the nanos printing in #print24:showSeconds:on:?

Stephan

Reply | Threaded
Open this post in threaded view
|

Re: Printing nanos in Time print24

David T. Lewis
On Tue, Oct 14, 2014 at 10:42:28AM +0200, Stephan Eggermont wrote:
> Ok, that is clear. I also have a need for time printing to seconds precision.
> Would it be better to keep the current behavior, fix the comments and
> add a method hhmmss or so, or to route printString to a printWithNanos
> and remove the nanos printing in #print24:showSeconds:on:?

Stephan,

That certainly sounds like a reasonable solution to me. I am away and cannot
look at it right now, but I would encourage you to add an update to the inbox
if you come up with a patch that handles this properly.

I think I recall a similar issue related to printing DateAndTime so you
may want to look and see if there is a solution there.

Dave