Commit e1c2c430 authored by 's avatar

Fixed a precision bug when DateTimes were created with no args.

parent 3b742826
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
"""Encapsulation of date/time values""" """Encapsulation of date/time values"""
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
import sys,os,regex,DateTimeZone import sys,os,regex,DateTimeZone
...@@ -401,6 +401,7 @@ class DateTime: ...@@ -401,6 +401,7 @@ class DateTime:
# Current time, exp in local timezone # Current time, exp in local timezone
t,tz=time(),self._localzone t,tz=time(),self._localzone
yr,mo,dy,hr,mn,sc=gmtime(int(t))[:6] yr,mo,dy,hr,mn,sc=gmtime(int(t))[:6]
sc=sc+(t-int(t))
s=(hr/24.0+mn/1440.0+sc/86400.0) s=(hr/24.0+mn/1440.0+sc/86400.0)
d=(self._julianday(yr,mo,dy)-jd1901)+s d=(self._julianday(yr,mo,dy)-jd1901)+s
yr,mo,dy,hr,mn,sc=localtime(t)[:6] yr,mo,dy,hr,mn,sc=localtime(t)[:6]
...@@ -412,6 +413,7 @@ class DateTime: ...@@ -412,6 +413,7 @@ class DateTime:
# Current time, exp in specified timezone # Current time, exp in specified timezone
t,tz=time(),self._tzinfo._zmap[lower(arg)] t,tz=time(),self._tzinfo._zmap[lower(arg)]
yr,mo,dy,hr,mn,sc=gmtime(t)[:6] yr,mo,dy,hr,mn,sc=gmtime(t)[:6]
sc=sc+(t-int(t))
s=(hr/24.0+mn/1440.0+sc/86400.0) s=(hr/24.0+mn/1440.0+sc/86400.0)
d=(self._julianday(yr,mo,dy)-jd1901)+s d=(self._julianday(yr,mo,dy)-jd1901)+s
_d=d+(self._tzinfo[tz].info(t)[0]/86400.0) _d=d+(self._tzinfo[tz].info(t)[0]/86400.0)
...@@ -450,6 +452,7 @@ class DateTime: ...@@ -450,6 +452,7 @@ class DateTime:
# Seconds from epoch, gmt # Seconds from epoch, gmt
t,tz=arg,self._localzone t,tz=arg,self._localzone
yr,mo,dy,hr,mn,sc=gmtime(int(t))[:6] yr,mo,dy,hr,mn,sc=gmtime(int(t))[:6]
sc=sc+(t-int(t))
s=(hr/24.0+mn/1440.0+sc/86400.0) s=(hr/24.0+mn/1440.0+sc/86400.0)
d=(self._julianday(yr,mo,dy)-jd1901)+s d=(self._julianday(yr,mo,dy)-jd1901)+s
yr,mo,dy,hr,mn,sc=localtime(t)[:6] yr,mo,dy,hr,mn,sc=localtime(t)[:6]
...@@ -485,6 +488,7 @@ class DateTime: ...@@ -485,6 +488,7 @@ class DateTime:
t,tz=args t,tz=args
tz=self._tzinfo._zmap[lower(tz)] tz=self._tzinfo._zmap[lower(tz)]
yr,mo,dy,hr,mn,sc=gmtime(t)[:6] yr,mo,dy,hr,mn,sc=gmtime(t)[:6]
sc=sc+(t-int(t))
s=(hr/24.0+mn/1440.0+sc/86400.0) s=(hr/24.0+mn/1440.0+sc/86400.0)
d=(self._julianday(yr,mo,dy)-jd1901)+s d=(self._julianday(yr,mo,dy)-jd1901)+s
_d=d+(self._tzinfo[tz].info(t)[0]/86400.0) _d=d+(self._tzinfo[tz].info(t)[0]/86400.0)
...@@ -529,7 +533,6 @@ class DateTime: ...@@ -529,7 +533,6 @@ class DateTime:
d=d-(self._tzinfo[tz].info(t)[0]/86400.0) d=d-(self._tzinfo[tz].info(t)[0]/86400.0)
s=d-int(d) s=d-int(d)
t=(d*86400.0)-EPOCH t=(d*86400.0)-EPOCH
else: else:
# Explicit format # Explicit format
yr,mo,dy=args[:3] yr,mo,dy=args[:3]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment