On Tue, Jun 26, 2001 at 07:00:53AM -0400, Chuck Esterbrook wrote:
| - do you have a regression test suite for this by any chance?
A simple one is below... it's the one that I used
the second time around (when I discovered the error).
| - you mention detecting "D M Y" where they are digits. How do you interpret
| "3/3/01", MDY or DMY? This seems ambiguous.
No easy way around that one. It's coded as M/D/Y
(per US standard). Someone is more than welcome to
make it configurable via a setting, or you could
make it give up totally with this case and return
the current date. In any case, the goal is to
have "some" operable date go into the system. When
the user refreshes the date will come back wrong
and they have a chance to fix it... after having
dates come back wrong, they will start to spell
out the months.
Best,
Clark
def dateRegress():
def x(y,m,d): return str(y) + "-" + str(m) + '-' + str(d)
tm = time.localtime()
yr = tm[0]
mo = tm[1]
dy = tm[2]
yrt = "1999"
mot = "4"
dyt = "11"
assert(x(yrt,mot,dyt) == dateString("1999 4 11"))
assert(x(yrt,mot,dyt) == dateString("1999 APR 11"))
assert(x(yrt,mot,dyt) == dateString("APR 11 1999"))
assert(x(yrt,mot,dyt) == dateString("11 APR 1999"))
assert(x(yrt,mot,dyt) == dateString("4 11 1999"))
assert(x(yrt,mot,1) == dateString("1999 APR"))
assert(x(yrt,mot,1) == dateString("1999 4"))
assert(x(yrt,mot,1) == dateString("4 1999"))
assert(x(yr,mot,dyt) == dateString("4 11"))
assert(x(yr,mot,dyt) == dateString("11 APR"))
assert(x(yr,mot,dyt) == dateString("APR 11"))
assert(x(yrt,mot,1) == dateString("APR 1999"))
assert(x(yrt,1,1) == dateString("1999"))
assert(x(yr,mo,dyt) == dateString("11"))
assert(x(yr,mot,1) == dateString("APR"))
assert(x(yr,mo,dy) == dateString("today"))
assert(None == dateString(""))
assert(None == dateString(None))
assert(x(yrt,mot,dyt) == dateString("11 apr 1999"))
assert(x(yrt,mot,dyt) == dateString("11 Apr 1999"))
assert(x(yrt,mot,dyt) == dateString("11 April 1999"))
assert(x(yrt,mot,dyt) == dateString("11 APRIL 1999"))
assert(x(yrt,mot,dyt) == dateString("11 april 1999"))
assert(x(yrt,mot,dyt) == dateString("APR 11, 1999"))
assert(x(yrt,mot,dyt) == dateString("4/11/1999"))
assert(x(yrt,mot,dyt) == dateString("4-11-1999"))
assert(x(yrt,mot,dyt) == dateString("1999-4-11"))
assert(x(yr,1,1) == dateString("Jan"))
assert(x(yr,2,1) == dateString("Feb"))
assert(x(yr,3,1) == dateString("Mar"))
assert(x(yr,4,1) == dateString("Apr"))
assert(x(yr,5,1) == dateString("May"))
assert(x(yr,6,1) == dateString("Jun"))
assert(x(yr,7,1) == dateString("Jul"))
assert(x(yr,8,1) == dateString("Aug"))
assert(x(yr,9,1) == dateString("Sep"))
assert(x(yr,10,1) == dateString("Oct"))
assert(x(yr,11,1) == dateString("Nov"))
assert(x(yr,12,1) == dateString("Dec"))
assert(x(yrt,mot,30) == dateString("1999-4-31"))
assert(x(2000,2,29) == dateString("29 FEB 2000"))
assert(x(2001,2,28) == dateString("29 FEB 2001"))
assert(x(2004,2,29) == dateString("29 FEB 2004"))
assert(x(2100,2,28) == dateString("29 FEB 2100"))
assert(x(1900,2,28) == dateString("29 FEB 1900"))
# ambiguous case, it chooses wrong... but don't fix.
assert(x(2000,1,11) == dateString("2000-13-11"))
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss