def createSchemaDateTime(year, month, day, hour, min, secs, localTz = True): if localTz: tz = ZLocalTimezone() else: tz = UTC_TIMEZONE dt = createDateTime(year, month, day, hour, min, secs, tz) return ZSchemaDateTime(dt)
def getIso8601Date(dateString): if not dateString: return None # check GMT time match YYYYMMDD:HHMMZ sent by some xml-rpc servers (wordpress 2.2+) m = re.match(XMLRPC_UTC_DATE_PATTERN, dateString) if m: (year, month, day, h, m, s) = m.groups() return ZSchemaDateTime(createDateTime(int(year), int(month), int(day), int(h), int(m), int(s), UTC_TIMEZONE)) # check local time match YYYYMMDD:HHMM sent by some xml-rpc servers. m = re.match(XMLRPC_LOCAL_DATE_PATTERN, dateString) if m: (year, month, day, h, m, s) = m.groups() return ZSchemaDateTime(createDateTime(int(year), int(month), int(day), int(h), int(m), int(s), ZLocalTimezone())) else: return ZSchemaDateTime(dateString)
def _initFromYYYYMMDDHHMMSS(self, year, month, day, hour, minute, second, tz=UTC_TIMEZONE): # Note: not sure about the millis param... dt = createDateTime(year, month, day, hour, minute, second, tz) self.dateTime = convertToUtcDateTime(dt)
def createStartDate(year, month, day): return createDateTime(year, month, day, 0, 0, 0, ZLocalTimezone())
def createEndDate(year, month, day): return createDateTime(year, month, day, 23, 59, 59, ZLocalTimezone())
def _initFromYYYYMMDDHHMMSS(self, year, month, day, hour, minute, second, tz = UTC_TIMEZONE): # Note: not sure about the millis param... dt = createDateTime(year, month, day, hour, minute, second, tz) self.dateTime = convertToUtcDateTime(dt)