how to store a date in a file with mxDateTime

David Bolen db3l at fitlinxx.com
Mon May 14 18:45:46 EDT 2001


"Scott Hathaway" <slhath at home.com> writes:

> I have tried the RelativeDateFrom(fileFromDate) method and
> DateTimeFrom(fileFromDate) method without success.

Converting the timestamp in your file to a DateTime value with
DateTimeFrom is sort of the "right" way to go, but older DateTime
versions (up until it switched to mx.DateTime) aren't as flexible as
they might be in parsing strings.  In particular, I think we had
problems with the US-standard approach of MM/DD/YY with two digit
years.  So depending on your format you might need to experiment a
little to see if you need to add some preprocessing.

You could of course build your own parser, but we've generally found
it easier to just augment our input if it's a well defined deficiency
(such as adding the leading 2 digits to years) and then use
DateTimeFrom.  You can experiment interactively with your string
formats to see just what parses the most accurately.

I do believe that in the 2.x releases (mx.DateTime) the parsing
function has been bolstered quite a bit and can handle more variety of
input.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list