Zope+FB+mx - DateTime errrrrrrrror....
chris.irish at libertydistribution.com
Thu Aug 19 20:32:41 CEST 2004
fowlertrainer at anonym.hu wrote:
> Hi !
> I think that I have been found a bug in mx.DateTime...
> I use FireBird, and in this RDBMS the datetime fields are "doubles".
> So if I set them to 0, the values the fields are '1899-12-30 01:00:00'.
> When I try to see this datetime as European format (YYYY.MM.DD HH:MM:SS)
> I get error.
> s='1899-12-30 01:00:00'
> s=nv.strftime('%Y.%m.%d. %H:%M:%S')
> # it is makes error
Well I'm no expert on the mx.Datetime module, but lets so if I can
help. In your example #1 I tried doing it in the interpretor exactly as
you did and ran into some problems. First, you set 's' equal to a
string of the date your wanting I presume. Then your calling the
builtin str method on it. Why when it's already a string? Then your
calling the DateTime method however it needs to be qualified through the
However your passing in s to this method as a string. In the
mx.DateTime docs it says and I quote,
Constructs a DateTime instance from the given values.
So you need to be passing in integer values except for the seconds
argument which can be a float. If you call the method in the correct
way it will return a datetime object of the date you want then you can
use strftime to format it in the european fasion yu desire. One final
note all datetime objects are created with a 24 hour time, not 12. So
5pm will be 17:00 after you string format the object, if my memory is
correct. Just remember that for if/when you take those times back out
of the database to display to a user you'll need to change them to a 12
hour time, unless they don't mind reading it like that. We use
PostgreSQL for our databases and whenever a time object is put into the
database it is automatically converted to ticks. I'm not sure if it's
the same way with yours or not. So when pulling a time back out it
would be converted like:
time = mx.DateTime.localtime(item_object_fromDB).strftime("%m/%d/%Y
There is also another method called strptime which parses a time string
according to a particular format but I haven't used it enough to
instruct you on it's us, but it could be helpful.
Hopefully something I said will help, be sure to look at the docs @:
Good Luck, Chris
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list