[Haizea] DateTime Datatypes

Borja Sotomayor borja at borjanet.com
Tue Jun 15 10:35:36 CDT 2010


Hi,

> Which types Lease's duration can be of? int, DateTime,?

The duration field itself has to be of type "Duration", which is a
type defined in Haizea and acts as a wrapper around several DateTimes
(the requested duration, the actual duration, etc.) However, the dates
themselves are all stored as DateTime (from the mx package).

> duration = floatNumber * Parser.DateTimeDeltaFromString(element.find("duration").get("time"))

This should work, although I'd recommend using the
round_datetime_function function in haizea.common.utils, as weird
things tend to happen if the seconds component is a floating point
number.

Also, remember that, assuming you have a variable "lease" of type
Lease, you can't just do:

Lease.duration = duration

You need to create a new Duration object:

Lease.duration = Duration(duration)

(you could also modify the fields of the existing Duration object
directly, but that is more error-prone)

Cheers!
-- 
Borja Sotomayor
PhD Candidate in Computer Science, University of Chicago
http://people.cs.uchicago.edu/~borja/


More information about the Haizea mailing list