[Zope-Checkins] CVS: Packages/DateTime - DateTime.py:1.85.12.11

Andreas Jung andreas at andreas-jung.com
Mon Aug 2 05:49:49 EDT 2004


Update of /cvs-repository/Packages/DateTime
In directory cvs.zope.org:/tmp/cvs-serv12205/lib/python/DateTime

Modified Files:
      Tag: Zope-2_7-branch
	DateTime.py 
Log Message:
backported copy constructor from trunk


=== Packages/DateTime/DateTime.py 1.85.12.10 => 1.85.12.11 ===
--- Packages/DateTime/DateTime.py:1.85.12.10	Fri Jun 25 11:43:06 2004
+++ Packages/DateTime/DateTime.py	Mon Aug  2 05:49:18 2004
@@ -516,6 +516,16 @@
     SyntaxError = SyntaxError
 
     def __init__(self,*args, **kw):
+        """Return a new date-time object"""
+
+        try:
+            return self._parse_args(*args, **kw)
+        except (DateError, TimeError, DateTimeError):
+            raise
+        except:
+            raise SyntaxError('Unable to parse %s, %s' % (args, kw))
+
+    def _parse_args(self,*args, **kw):
         """Return a new date-time object
 
         A DateTime object always maintains its value as an absolute
@@ -707,7 +717,17 @@
             if arg=='':
                 raise SyntaxError, arg
 
-            if isinstance(arg, (unicode, str)) and arg.lower() in self._tzinfo._zidx:
+            if isinstance(arg, DateTime):
+                """ Construct a new DateTime instance from a given DateTime instance """
+                t = arg.timeTime()
+                lt = safelocaltime(t)
+                tz = self.localZone(lt)
+                ms = (t - math.floor(t))
+                s,d = _calcSD(t)
+                yr,mo,dy,hr,mn,sc=lt[:6]
+                sc=sc+ms
+
+            elif isinstance(arg, (unicode, str)) and arg.lower() in self._tzinfo._zidx:
                 # Current time, to be displayed in specified timezone
                 t,tz=time(),self._tzinfo._zmap[arg.lower()]
                 ms=(t-math.floor(t))



More information about the Zope-Checkins mailing list