[Bug+Patch] Microseconds in DateTime
[Sent to main list, ignored. Retrying here...] The __str__ function in DateTime.DateTime cuts off two precision digits from the time returned by time.time(), falling off to tenths of milliseconds instead of keeping the microseconds. If it feels unrighteous to put the hard work of gettimeofday() to waste, apply the patch below to lib/python/DateTime/DateTime.py, and get back that microsecond precision. Yes, on some hardware/software platforms those microseconds are significant, and yes, they can be useful in many situations. Here is the patch. --- DateTime.py Thu Jul 05 17:55:29 2001 +++ DateTime.py.NEW Mon Oct 22 16:00:36 2001 @@ -1558,11 +1558,11 @@ y,m,d =self._year,self._month,self._day h,mn,s,t=self._hour,self._minute,self._second,self._tz if(h+mn+s): - if (s-int(s))> 0.0001: + if (s-int(s)) >= 0.000001: try: # For the seconds, print two digits # before the decimal point. - subsec = split('%g' % s, '.')[1] + subsec = split('%f' % s, '.')[1] return '%4.4d/%2.2d/%2.2d %2.2d:%2.2d:%2.2d.%s %s' % ( y,m,d,h,mn,s,subsec,t) except: -- Nicola Larosa - nico@tekNico.net
[Sent to main list, ignored. Retrying here...]
OK, so nobody cares. Anyway, the BugCollector is down, what is a poor guy to do to get the fix in? Of course, if it is a very stupid thing to do, I would really like to know. :^) Thanks. -- "Mozilla will be around long after nobody can remember just quite what Internet Explorer actually used to be." AirLace on Slashdot Nicola Larosa - nico@tekNico.net
Nicola Larosa wrote:
[Sent to main list, ignored. Retrying here...]
OK, so nobody cares. Anyway, the BugCollector is down, what is a poor guy to do to get the fix in?
Of course, if it is a very stupid thing to do, I would really like to know. :^)
Just to voice an opinion, I like the patch and I think it should go in. Now what really matters is if someone with CVS commit powers agree with me :-) cheers, Leo
On Wed, 24 Oct 2001, Nicola Larosa wrote:
OK, so nobody cares. Anyway, the BugCollector is down, what is a poor guy to do to get the fix in?
Of course, if it is a very stupid thing to do, I would really like to know. :^)
Well, I like the idea personally, but let me play devil's advocate here for a minute. Suppose there are platforms where those extra couple of digits are not valid. Suppose further that the common paradigm of using str(int(DateTime())) as a "unique id" is employed. Now suppose you move that code from a Unix platform to some platform that doesn't supply the extra digits. Suddenly your code that used to provide uniqueness down to a fairly tight hit interval is much more fragile. Is this a real concern? I don't really think so. But it's the only objection I can think of <grin>. --RDM
R. David Murray wrote:
On Wed, 24 Oct 2001, Nicola Larosa wrote:
OK, so nobody cares. Anyway, the BugCollector is down, what is a poor guy to do to get the fix in?
Of course, if it is a very stupid thing to do, I would really like to know. :^)
Well, I like the idea personally, but let me play devil's advocate here for a minute. Suppose there are platforms where those extra couple of digits are not valid. Suppose further that the common paradigm of using str(int(DateTime())) as a "unique id" is employed. Now suppose you move that code from a Unix platform to some platform that doesn't supply the extra digits. Suddenly your code that used to provide uniqueness down to a fairly tight hit interval is much more fragile.
Is this a real concern? I don't really think so. But it's the only objection I can think of <grin>.
Well, I'm usually against cathering to the lowest common denominator, so I'll agree with you here that this is not a real concern :-) cheers, Leo
participants (3)
-
Leonardo Rochael Almeida -
Nicola Larosa -
R. David Murray