[egenix-users] At what year does (yy, mm, dd) become (19yy, mm,
dd)?
M.-A. Lemburg
mal at egenix.com
Wed May 7 14:36:09 CEST 2008
On 2008-05-07 12:09, Dick Moores wrote:
> For mxDateTime.
>
> I know I saw this in the manual, but I can't locate it again.
Note about the Y2K problems:
The parser can only handle years with at least 2 digits. 2
digit year values get expanded by adding the century using
DateTime.add_century(), while 3 digit year get converted
literally. To have 2 digit years also be interpreted literally,
add leading zeros, e.g. year 99 must be written as 099 or 0099.
def add_century(year):
""" Sliding window approach to the Y2K problem: adds a suitable
century to the given year and returns it as integer.
The window used depends on the current year (at import time).
If adding the current century to the given year gives a year
within the range current_year-70...current_year+30 [both
inclusive], then the current century is added. Otherwise the
century (current + 1 or - 1) producing the smallest difference is
chosen.
"""
HTH,
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, May 07 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the egenix-users
mailing list