Dick Moores | 7 May 12:05

At what year does (yy, mm, dd) become (19yy, mm, dd)?

For mxDateTime.

I know I saw this in the manual, but I can't locate it again.

Thanks,

Dick Moores

_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users

M.-A. Lemburg | 7 May 13:36
Favicon

Re: At what year does (yy, mm, dd) become (19yy, mm, dd)?

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
(Continue reading)


Gmane