From: Stewart Midwinter <stewart.midwinter@gm...> - 2005-12-03 09:26:25
When a single record from my database is displayed in the browser, the
observation time & date have a different format in the development
server (Apache 2 running on WinXP) than in the production server
(Apache 2 running on Mandrake Linux 10.2). Here's a copy of the
record, as printed in the browser:
Production: (as observed on 2005-10-13 00:00:00.00 at 18:47:41.00 by midto=
Development: (as observed on 2005-10-13 at 18:47:41 by midtoad)
The format displayed by the development server is the desired one.
When I check the data in mySql database with a command-line interface,
the display is identical on both systems.
When I run an sqlobject script in test mode at the command line, the
display of date and time is identical in both systems.
mysql> select date, starttime from route where id=3D84;
| date | starttime |
| 2005-10-13 | 18:47:41 |
The suspicion is thus that inside SQLObject, the format
representation of a DateTime? object differs from Linux to Windows.
This suspicion seems to be borne out when I open a python shell in
both platforms and run SQLObject queries on each:
selme =3D Route.select(Route.q.id=3D=3D84)
for sel in selme:
print sel.date, sel.starttime
>>> 2005-10-13 18:47:41 [development on WindowsXP]
>>> <DateTime object for '2005-10-13 00:00:00' at b7bcdc28>, <DateTime
Delta object for '18:47:41.00' at b7911958> [production on Linux]
I opened a Python shell on both platforms, and made a connection to
my database using MySQLdb module. I then executed a query:
db.query("""select date, starttime from route where id=3D84""")
>>> (('2005-10-13','18:47:41'),) [production on Linux]
>>> ((datetime.date(2005, 10, 13), datetime.timedelta(0, 67661)),)
[development on WinXP]
So maybe the difference is actually in mySQLdb and not in SQLobject?
I can work-around by testing the string that is returned in both
platforms, and delete off the extra erroneous time string that is
provided in Linux. But still, it would be interesting to know why this
has anyone else noticed anything like this before?
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
Stewart Midwinter <stewart.midwinter@...> writes:
> I can work-around by testing the string that is returned in both
> platforms, and delete off the extra erroneous time string that is
> provided in Linux. But still, it would be interesting to know why this
Don't do that. What you should do is using strftime() to format the date as
you wish. For example, if you have a myDate field and wanted dates like
mm-dd-yyyy you'd use myDate.strftime('%m-%d-%Y'). This way you ensure that it
will be always the same string.
Jorge Godoy <godoy@...>