Example #1
0
    def testFromPtp(self):
        t = ptptime.timefromptp(0x0000000000000000)
        if not isinstance(t, ptptime.ptptime):
            assert False, "Incorrect Instance type: '{0}'".format(str(t))
        d = {'year': 1970, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': 0}
        checkAttributes(t, d)
        
        t = ptptime.timefromptp(0x386d438000000000)
        if not isinstance(t, ptptime.ptptime):
            assert False, "Incorrect Instance type: '{0}'".format(str(t))
        d = {'year': 2000, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': 0}
        checkAttributes(t, d)

        t = ptptime.timefromptp(0x386d43A000000000, leapyear=-1)
        if not isinstance(t, ptptime.ptptime):
            assert False, "Incorrect Instance type: '{0}'".format(str(t))
        d = {'year': 2000, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': -1}
        checkAttributes(t, d)

        t = ptptime.timefromptp(0x386d438100000000, leapyear=1)
        if not isinstance(t, ptptime.ptptime):
            assert False, "Incorrect Instance type: '{0}'".format(str(t))
        d = {'year': 2000, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': 1}
        checkAttributes(t, d)

        t = ptptime.timefromptp(0x14b0823f3b9ac618)
        if not isinstance(t, ptptime.ptptime):
            assert False, "Incorrect Instance type: '{0}'".format(str(t))
        d = {'year': 1980, 'month': 12 , 'day': 31, 'hour': 11, 'minute': 59, 'second': 59, 'microsecond': 999999, 'nanosecond': 0, 'leapyear': 0}
        checkAttributes(t, d)

        t = ptptime.timefromptp(0x14b12aff3b9ac618)
        if not isinstance(t, ptptime.ptptime):
            assert False, "Incorrect Instance type: '{0}'".format(str(t))
        d = {'year': 1980, 'month': 12 , 'day': 31, 'hour': 23, 'minute': 59, 'second': 59, 'microsecond': 999999, 'nanosecond': 0, 'leapyear': 0}
        checkAttributes(t, d)

        d = {'year': 1981, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)

        t = t - ptptime.timedelta(microseconds=1)
        d = {'year': 1980, 'month': 12 , 'day': 31, 'hour': 23, 'minute': 59, 'second': 59, 'microsecond': 999999, 'nanosecond': 0, 'leapyear': 0}
        checkAttributes(t, d)
        expected = 0x14b12aff3b9ac618
        if not t.ptp == expected:
                assert False, "Incorrect PTP value: 0x{0:016x}, expected 0x{1:016x}".format(t.ptp, expected)
        
        t = t - ptptime.timedelta(hours=12)
        d = {'year': 1980, 'month': 12 , 'day': 31, 'hour': 11, 'minute': 59, 'second': 59, 'microsecond': 999999, 'nanosecond': 0, 'leapyear': 0}
        checkAttributes(t, d)
        expected = 0x14b0823f3b9ac618
        if not t.ptp == expected:
                assert False, "Incorrect PTP value: 0x{0:016x}, expected 0x{1:016x}".format(t.ptp, expected)
Example #2
0
    def testPTPSubtraction(self):
        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(days=1)
        d['day'] = 11
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-11 16:24:34.123456:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(hours=1)
        d['hour'] = 15
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 15:24:34.123456:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(minutes=1)
        d['minute'] = 23
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:23:34.123456:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(seconds=1)
        d['second'] = 33
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:33.123456:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))


        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(microseconds=1)
        d['microsecond'] = 123455
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123455:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))


        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 54, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 53
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123456:053":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 999
        d['microsecond'] = 123455
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123455:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 999
        d['microsecond'] = 999999
        d['second'] = 33
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:33.999999:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 999
        d['microsecond'] = 999999
        d['second'] = 59
        d['minute'] = 23
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:23:59.999999:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 999
        d['microsecond'] = 999999
        d['second'] = 59
        d['minute'] = 59
        d['hour'] = 15
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 15:59:59.999999:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 999
        d['microsecond'] = 999999
        d['second'] = 59
        d['minute'] = 59
        d['hour'] = 23
        d['day'] = 11
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-11 23:59:59.999999:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 999
        d['microsecond'] = 999999
        d['second'] = 59
        d['minute'] = 59
        d['hour'] = 23
        d['day'] = 31
        d['month'] = 10
        checkAttributes(tn, d)
        if not str(tn) == "1972-10-31 23:59:59.999999:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 999
        d['microsecond'] = 999999
        d['second'] = 59
        d['minute'] = 59
        d['hour'] = 23
        d['day'] = 31
        d['month'] = 12
        d['year'] = 1971
        checkAttributes(tn, d)
        if not str(tn) == "1971-12-31 23:59:59.999999:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1970, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 999
        d['microsecond'] = 999999
        d['second'] = 59
        d['minute'] = 59
        d['hour'] = 23
        d['day'] = 31
        d['month'] = 12
        d['year'] = 1969
        checkAttributes(tn, d)
        if not str(tn) == "1969-12-31 23:59:59.999999:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1001)
        d['nanosecond'] = 999
        d['microsecond'] = 999998
        d['second'] = 59
        d['minute'] = 59
        d['hour'] = 23
        d['day'] = 31
        d['month'] = 12
        d['year'] = 1971
        checkAttributes(tn, d)
        if not str(tn) == "1971-12-31 23:59:59.999998:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 1 , 'day': 1, 'hour': 0, 'minute': 0, 'second': 0, 'microsecond': 0, 'nanosecond': 501, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'],d['nanosecond'])
        checkAttributes(t, d)
        tn = t - ptptime.timedelta(nanoseconds=1002)
        d['nanosecond'] = 499
        d['microsecond'] = 999999
        d['second'] = 59
        d['minute'] = 59
        d['hour'] = 23
        d['day'] = 31
        d['month'] = 12
        d['year'] = 1971
        checkAttributes(tn, d)
        if not str(tn) == "1971-12-31 23:59:59.999999:499":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))
Example #3
0
    def testPTPAddition(self):
        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(days=1)
        d['day'] = 13
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-13 16:24:34.123456:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(hours=1)
        d['hour'] = 17
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 17:24:34.123456:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(minutes=1)
        d['minute'] = 25
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:25:34.123456:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(seconds=1)
        d['second'] = 35
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:35.123456:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))


        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(microseconds=1)
        d['microsecond'] = 123457
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123457:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))


        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 1
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123456:001":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=999)
        d['nanosecond'] = 999
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123456:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=1000)
        d['nanosecond'] = 0
        d['microsecond'] = 123457
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123457:000":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=1001)
        d['nanosecond'] = 1
        d['microsecond'] = 123457
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123457:001":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 999999, 'nanosecond': 0, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=1001)
        d['nanosecond'] = 1
        d['microsecond'] = 0
        d['second'] = 35
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:35.000000:001":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 1, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'], d['nanosecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 2
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123456:002":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 501, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'], d['nanosecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=501)
        d['nanosecond'] = 2
        d['microsecond'] = 123457
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123457:002":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 1, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'], nanosecond=d['nanosecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=1)
        d['nanosecond'] = 2
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123456:002":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))

        d = {'year': 1972, 'month': 11 , 'day': 12, 'hour': 16, 'minute': 24, 'second': 34, 'microsecond': 123456, 'nanosecond': 501, 'leapyear': False}
        t = ptptime.ptptime(d['year'],d['month'],d['day'],d['hour'],d['minute'],d['second'],d['microsecond'], nanosecond=d['nanosecond'])
        checkAttributes(t, d)
        tn = t + ptptime.timedelta(nanoseconds=501)
        d['nanosecond'] = 2
        d['microsecond'] = 123457
        checkAttributes(tn, d)
        if not str(tn) == "1972-11-12 16:24:34.123457:002":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(tn))
    def testNanoTimeDeltaInit(self):
        d = ('days', 'seconds', 'microseconds', 'nanoseconds','max', 'min','total_seconds')
        t = ptptime.timedelta()
        hasAttributes(t, d)
        
        t = ptptime.timedelta(days=1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['days'] = 1
        checkAttributes(t, d)

        if not str(t) == "1 day, 0:00:00":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(hours=1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['seconds'] = 3600
        checkAttributes(t, d)

        if not str(t) == "1:00:00":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(minutes=1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['seconds'] = 60
        checkAttributes(t, d)
    
        if not str(t) == "0:01:00":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(seconds=1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['seconds'] = 1
        checkAttributes(t, d)
    
        if not str(t) == "0:00:01":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(microseconds=1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['microseconds'] = 1
        checkAttributes(t, d)
    
        if not str(t) == "0:00:00.000001":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(nanoseconds=1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['nanoseconds'] = 1
        checkAttributes(t, d)

        t = ptptime.timedelta(nanoseconds=1001)
        d = {'days': 0, 'seconds': 0, 'microseconds': 1, 'nanoseconds': 0,}
        d['nanoseconds'] = 1
        checkAttributes(t, d)

        if not str(t) == "0:00:00.000001:001":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(days=1, hours=1, minutes=1, seconds=1, microseconds=1, nanoseconds=1)
        d = {'days': 1, 'seconds': 3661, 'microseconds': 1, 'nanoseconds': 1,}
        checkAttributes(t, d)

        if not str(t) == "1 day, 1:01:01.000001:001":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(days=-1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['days'] = -1
        checkAttributes(t, d)

        if not str(t) == "-1 day, 0:00:00":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(hours=-1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['days'] = -1
        d['seconds'] = 82800
        checkAttributes(t, d)

        if not str(t) == "-1 day, 23:00:00":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(minutes=-1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['days'] = -1
        d['seconds'] = 86340
        checkAttributes(t, d)
    
        if not str(t) == "-1 day, 23:59:00":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(seconds=-1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['days'] = -1
        d['seconds'] = 86399
        checkAttributes(t, d)
    
        if not str(t) == "-1 day, 23:59:59":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(microseconds=-1)
        d = {'days': 0, 'seconds': 0, 'microseconds': 0, 'nanoseconds': 0,}
        d['days'] = -1
        d['seconds'] = 86399
        d['microseconds'] = 999999
        checkAttributes(t, d)
    
        if not str(t) == "-1 day, 23:59:59.999999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(days=-1, hours=-1)
        d = {'days': -2, 'seconds': 82800, 'microseconds': 0, 'nanoseconds': 0,}
        checkAttributes(t, d)

        if not str(t) == "-2 days, 23:00:00":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(days=-1, hours=-1, minutes=-1)
        d = {'days': -2, 'seconds': 82740, 'microseconds': 0, 'nanoseconds': 0,}
        checkAttributes(t, d)

        if not str(t) == "-2 days, 22:59:00":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(days=-1, hours=-1, minutes=-1, seconds=-1)
        d = {'days': -2, 'seconds': 82739, 'microseconds': 0, 'nanoseconds': 0,}
        checkAttributes(t, d)

        if not str(t) == "-2 days, 22:58:59":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(days=-1, hours=-1, minutes=-1, seconds=-1, microseconds=-1, nanoseconds=1)
        d = {'days': -2, 'seconds': 82738, 'microseconds': 999999, 'nanoseconds': 1,}
        checkAttributes(t, d)

        if not str(t) == "-2 days, 22:58:58.999999:001":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(nanoseconds=-1)
        d = {'days': -1, 'seconds': 86399, 'microseconds': 999999, 'nanoseconds': 999,}
        checkAttributes(t, d)

        if not str(t) == "-1 day, 23:59:59.999999:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(nanoseconds=-1001)
        d = {'days': -1, 'seconds': 86399, 'microseconds': 999998, 'nanoseconds': 999,}
        checkAttributes(t, d)

        if not str(t) == "-1 day, 23:59:59.999998:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(microseconds=-1, nanoseconds=-1)
        d = {'days': -1, 'seconds': 86399, 'microseconds': 999998, 'nanoseconds': 999,}
        checkAttributes(t, d)

        if not str(t) == "-1 day, 23:59:59.999998:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(seconds=-1, microseconds=-1, nanoseconds=-1)
        d = {'days': -1, 'seconds': 86398, 'microseconds': 999998, 'nanoseconds': 999,}
        checkAttributes(t, d)

        if not str(t) == "-1 day, 23:59:58.999998:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))

        t = ptptime.timedelta(minutes=-1, seconds=-1, microseconds=-1, nanoseconds=-1)
        d = {'days': -1, 'seconds': 86338, 'microseconds': 999998, 'nanoseconds': 999,}
        checkAttributes(t, d)

        if not str(t) == "-1 day, 23:58:58.999998:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))


        t = datetime.timedelta(hours=-1, minutes=-1, seconds=-1, microseconds=-1)
        if not str(t) == "-1 day, 22:58:58.999999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))
        d = {'days': -1, 'seconds': 82738, 'microseconds': 999999}
        checkAttributes(t, d)

        t = ptptime.timedelta(hours=-1, minutes=-1, seconds=-1, microseconds=-1)
        d = {'days': -1, 'seconds': 82738, 'microseconds': 999999, 'nanoseconds': 0,}
        checkAttributes(t, d)

        if not str(t) == "-1 day, 22:58:58.999999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))
        
        t = ptptime.timedelta(hours=-1, minutes=-1, seconds=-1, microseconds=-1, nanoseconds=-1)
        d = {'days': -1, 'seconds': 82738, 'microseconds': 999998, 'nanoseconds': 999,}
        checkAttributes(t, d)

        if not str(t) == "-1 day, 22:58:58.999998:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))
        

        t = ptptime.timedelta(days=-1, hours=-1, minutes=-1, seconds=-1, microseconds=-1, nanoseconds=-1)
        d = {'days': -2, 'seconds': 82738, 'microseconds': 999998, 'nanoseconds': 999,}
        checkAttributes(t, d)

        if not str(t) == "-2 days, 22:58:58.999998:999":
                assert False, "Incorrect Time Formatting: '{0}'".format(str(t))