7 May 16:04
Re: At what year does (yy, mm, dd) become (19yy, mm, dd)?
From: M.-A. Lemburg <mal@...>
Subject: Re: At what year does (yy, mm, dd) become (19yy, mm, dd)?
Newsgroups: gmane.comp.python.egenix.user
Date: 2008-05-07 14:04:22 GMT
Subject: Re: At what year does (yy, mm, dd) become (19yy, mm, dd)?
Newsgroups: gmane.comp.python.egenix.user
Date: 2008-05-07 14:04:22 GMT
On 2008-05-07 15:56, Dick Moores wrote: > On Wed, May 7, 2008 at 4:36 AM, M.-A. Lemburg <mal@...> wrote: >> 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. > > Sorry, but I can't follow that. Please give some examples. From my own > testing, I can see that for current year 2008, if 2-digit years are > represented by yy, then if yy <= 38, the century is the 21st (20yy). > Whereas if yy > 39, the century is the 20th (19yy). But I don't(Continue reading)
RSS Feed