[Zope] - Convert database date to Zope date
skip@calendar.com (Skip Montanaro)
skip@calendar.com (Skip Montanaro)
Wed, 6 Jan 1999 16:46:18 -0500 (EST)
Michael> How does one convert a database date value to a Zope date
Michael> value. I'm trying to use a date value retrieved from a query of
Michael> a MySQL database in the var command with the date formatting
Michael> options. If I just use the raw value from the query, I get an
Michael> error. Is there a way to convert this to a Zope date data type?
I don't know sure what sort of value MySQL returns, but in my application I
store timestamps as floating point values (such as returned by
time.time()). I was able to access them from DTML by converting them to
DateTime objects, e.g.:
e.start = DateTime.DateTime(e.start)
then access it as appropriate from DTML:
<!--#var start fmt=aDay--> ...
I was a bit disappointed to discover there is no exposure of strftime
functionality through DateTime objects. The static date formats provided
don't meet my needs. To generate a date in the format I want I wind up
making at least four #var references per date. If there's no strong
objection, I will add an ftime (or strftime) method to DateTime objects that
can at least be called through a var tag with an expr attribute.
Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/
skip@calendar.com | Musi-Cal: http://concerts.calendar.com/
518-372-5583