<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<a class="moz-txt-link-abbreviated" href="mailto:fowlertrainer@anonym.hu">fowlertrainer@anonym.hu</a> wrote:
<blockquote cite="mid40F69228.4060901@anonym.hu" type="cite">Hi !
<br>
<br>
I think that I have been found a bug in mx.DateTime...
<br>
So:
<br>
I use FireBird, and in this RDBMS the datetime fields are "doubles".
<br>
So if I set them to 0, the values the fields are '1899-12-30 01:00:00'.
<br>
<br>
When I try to see this datetime as European format (YYYY.MM.DD
HH:MM:SS)
<br>
I get error.
<br>
<br>
Example1:
<br>
s='1899-12-30 01:00:00'
<br>
nv=str(s)
<br>
nv=DateTime(s)
<br>
s=nv.strftime('%Y.%m.%d. %H:%M:%S')
<br>
# it is makes error
<br>
<br>
</blockquote>
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 mx.DateTime module <br>
i.e. <br>
import mx.DateTime<br>
mx.DateTime.DateTime(s)<br>
<br>
However your passing in s to this method as a string. In the
mx.DateTime docs it says and I quote, "<code><font color="#000099">DateTime(year,month=1,day=1,hour=0,minute=0,second=0.0)</font></code><br>
Constructs a DateTime instance from the given values.<a name="DateTime"><a
name="DateTime"></a></a><br>
<br>
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: <br>
<br>
time = mx.DateTime.localtime(item_object_fromDB).strftime("%m/%d/%Y
etc....")<br>
<br>
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.<br>
<br>
Hopefully something I said will help, be sure to look at the docs @:<br>
<br>
<a class="moz-txt-link-freetext" href="http://www.egenix.com/files/python/mxDateTime.html#DateTime">http://www.egenix.com/files/python/mxDateTime.html#DateTime</a><br>
and<br>
<a class="moz-txt-link-freetext" href="http://docs.python.org/lib/module-time.html">http://docs.python.org/lib/module-time.html</a><br>
<br>
Good Luck, Chris<br>
<br>
<br>
</body>
</html>