def check_timestamps (start, end, date) : t = end if end == '24:00' : t = '00:00' dstart = Date (start, offset = 0) dend = Date (t, offset = 0) dstart.year = dend.year = date.year dstart.month = dend.month = date.month dstart.day = dend.day = date.day if end == '24:00' : dend += common.day dend.hours = dend.seconds = dend.minutes = 0 if dstart > dend : raise Reject, _ ("start and end must be on same day and start <= end.") if dstart.timestamp () % 900 or dend.timestamp () % 900 : raise Reject, _ ("Times must be given in quarters of an hour") dur = (dend - dstart).as_seconds () / 3600. ep = dend.pretty (hour_format) if end == '24:00' : assert ep == '00:00' ep = end return dstart, dend, dstart.pretty (hour_format), ep, dur
def testTimestamp(self): ae = self.assertEqual date = Date("2038") ae(date.timestamp(), 2145916800) date = Date("1902") ae(date.timestamp(), -2145916800) date = Date(time.gmtime(0)) ae(date.timestamp(), 0) ae(str(date), "1970-01-01.00:00:00") date = Date(time.gmtime(0x7FFFFFFF)) ae(date.timestamp(), 2147483647) ae(str(date), "2038-01-19.03:14:07") date = Date("1901-12-13.20:45:52") ae(date.timestamp(), -0x80000000L) ae(str(date), "1901-12-13.20:45:52") date = Date("9999") ae(date.timestamp(), 253370764800.0) date = Date("0033") ae(date.timestamp(), -61125753600.0) ae(str(date), "0033-01-01.00:00:00")
def testTimestamp(self): ae = self.assertEqual date = Date('2038') ae(date.timestamp(), 2145916800) date = Date('1902') ae(date.timestamp(), -2145916800) date = Date(time.gmtime(0)) ae(date.timestamp(), 0) ae(str(date), '1970-01-01.00:00:00') date = Date(time.gmtime(0x7FFFFFFF)) ae(date.timestamp(), 2147483647) ae(str(date), '2038-01-19.03:14:07') date = Date('1901-12-13.20:45:52') ae(date.timestamp(), -0x80000000L) ae(str(date), '1901-12-13.20:45:52') date = Date('9999') ae (date.timestamp(), 253370764800.0) date = Date('0033') ae (date.timestamp(), -61125753600.0) ae(str(date), '0033-01-01.00:00:00')
def testTimestamp(self): ae = self.assertEqual date = Date('2038') ae(date.timestamp(), 2145916800) date = Date('1902') ae(date.timestamp(), -2145916800) date = Date(time.gmtime(0)) ae(date.timestamp(), 0) ae(str(date), '1970-01-01.00:00:00') date = Date(time.gmtime(0x7FFFFFFF)) ae(date.timestamp(), 2147483647) ae(str(date), '2038-01-19.03:14:07') date = Date('1901-12-13.20:45:52') ae(date.timestamp(), -0x80000000L) ae(str(date), '1901-12-13.20:45:52') date = Date('9999') ae(date.timestamp(), 253370764800.0) date = Date('0033') ae(date.timestamp(), -61125753600.0) ae(str(date), '0033-01-01.00:00:00')
def is_end_of_week (date) : date = Date (str (date)) wday = gmtime (date.timestamp ())[6] return wday == 6