[Pharo-project] DateAndTime and TimeStamp precision

Henrik Johansen henrik.s.johansen at veloxit.no
Tue Feb 16 12:56:14 EST 2010

Den 16.02.2010 18:32, skrev Miguel Enrique Cobá Martinez:
> El mar, 16-02-2010 a las 18:26 +0100, Henrik Johansen escribió:
>> Den 16.02.2010 16:44, skrev Marcus Denker:
>>> On Feb 16, 2010, at 4:39 PM, Miguel Enrique Cobá Martinez wrote:
>>>> El mar, 16-02-2010 a las 14:39 +0100, Luc Fabresse escribió:
>>>>> Hi,
>>>>>  I think it is related to: http://code.google.com/p/pharo/issues/detail?id=982
>>>>>  If I remember well, there is no primitive with nano second accuracy  
>>>>> so it is impossible to have it in real.
>>>> Yes, and indeed nano second accuracy is overkill for my current problem.
>>>> I only want some given precision so that
>>>> DateAndTime now < DateAndTime now
>>>> is always true, so that can be used to order events (object creation in
>>>> this case) using the date.
>> But it's not. DateAndTime now <= DateAndTime now.
>> If you are batching them together so close that resolution is an issue
>> why not rewrite it to something like:
>> currTime:= DateAndTime now.
>> obj Count:= 0.
>> someLoop whileTrue: [
>>     newObj := aClass new time: currTime+ objCount; yourself.
>>     currTime := currTime +1.
>>     ]
> Thank you very much! I am doing something similar to this.

If this resembles your approach, just remember to make sure that the
function is never called frequently.
If it is, you'll have to account for (if likely enough to be a potential
a) The function being called twice in the same DateAndTime resolution
interval (code to handle this which will be different based on whether
you want to protect against sequential or concurrent calls)
b) You don't allocate so many objects you get an overflow into the next
now, then call again.


More information about the Pharo-dev mailing list