[Scipy-svn] r2779 - trunk/Lib/sandbox/timeseries

scipy-svn@scip... scipy-svn@scip...
Wed Feb 28 14:24:30 CST 2007


Author: mattknox_ca
Date: 2007-02-28 14:24:21 -0600 (Wed, 28 Feb 2007)
New Revision: 2779

Modified:
   trunk/Lib/sandbox/timeseries/tdates.py
Log:
- eliminated requirement of mx.DateTime
- renamed mxDate parameter in Date constructor to datetime
- still accepts mx.DateTime instances for the datetime parameter, but these are converted to regular datetime objects internally

Modified: trunk/Lib/sandbox/timeseries/tdates.py
===================================================================
--- trunk/Lib/sandbox/timeseries/tdates.py	2007-02-28 20:21:35 UTC (rev 2778)
+++ trunk/Lib/sandbox/timeseries/tdates.py	2007-02-28 20:24:21 UTC (rev 2779)
@@ -31,10 +31,9 @@
     from mx.DateTime import DateTimeType
 except ImportError:
     class DateTimeType: pass
-    
-    
-from mx.DateTime.Parser import DateFromString as mxDFromString
 
+from parser import DateFromString, DateTimeFromString    
+
 import tcore as corelib
 import cseries
 
@@ -148,7 +147,10 @@
                 value = int(value)
         
             if isinstance(value, str):
-                self.datetime = mx_to_datetime(mxDFromString(value))
+                if self.freqstr in ('H', 'T', 'S'):
+                    self.datetime = DateTimeFromString(value)
+                else:
+                    self.datetime = DateFromString(value)
             elif self.freqstr == 'A':
                 self.datetime = dt.datetime(value, 1, 1)
             elif self.freqstr == 'B':
@@ -175,7 +177,10 @@
                                 dt.timedelta(days=(value-1)*7)
         
         elif string is not None:
-            self.datetime = mx_to_datetime(mxDFromString(string))
+            if self.freqstr in ('H', 'T', 'S'):
+                self.datetime = DateTimeFromString(string)
+            else:
+                self.datetime = DateFromString(string)
             
         elif datetime is not None:
             if isinstance(datetime, DateTimeType):
@@ -867,7 +872,7 @@
     # Case #1: dates as strings .................
     if dlist.dtype.kind == 'S':
         #...construct a list of ordinals
-        ords = numpy.fromiter((mxDFromString(s).absdays for s in dlist),
+        ords = numpy.fromiter((DateTimeFromString(s).toordinal() for s in dlist),
                                float_)
         ords += 1
         #...try to guess the frequency



More information about the Scipy-svn mailing list