5 May 10:36
mxDateTime problem
From: Dick Moores <rdmoores@...>
Subject: mxDateTime problem
Newsgroups: gmane.comp.python.egenix.user
Date: 2008-05-05 08:37:16 GMT
Subject: mxDateTime problem
Newsgroups: gmane.comp.python.egenix.user
Date: 2008-05-05 08:37:16 GMT
Use this file for temporary saving. E.g. for drafting an email. Please see my daysDelta24.py at <http://py77.python.pastebin.com/f5d8a35d> "Compute the difference in days (and weeks and days) between 2 dates. E.g., The difference between 07/04/1776 and 09/11/2001 is 82248 days Or 11749 weeks and 5 days" The user is instructed to "Enter date as month/day/year, or enter nothing for today", for both dates. If for one date he chooses to enter nothing in order to make that date today's date, the script fails--the computed difference between the dates will be short by 1. Thus, if the dates are 5/5/2008 (today's date entered by entering nothing) and 5/8/2008, the computed difference will be 2. If instead, both of these dates had been entered "manually", the computed difference will be 3. (See outputs #3 and #4, lines 107-126) I believe the error is caused by getDate() returning DT.now() when the user enters "". DT.now() is, for example, 2008-05-05 00:51:34.00 (my local time at time of writing), not 2008-05-05 00:00:00.00, whereas the other date entered, for example 5/8/2008, will be returned as 2008-05-11 00:00:00.00. >>> from mx import DateTime as DT >>> print DT.now() 2008-05-05 00:51:34.00 >>> dstr = "5/8/2008" >>> print DT.Parser.DateFromString(dstr, ('us',)) 2008-05-08 00:00:00.00 >>>(Continue reading)
RSS Feed