예제 #1
0
    def test_time_zones(self):
        timestr = "20051213141205Z"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(0, time.tzinfo.houroffset)
        assert_equal(0, time.tzinfo.minoffset)
        offset = time.tzinfo.utcoffset(time.tzinfo.dst())
        assert_equal(0, offset.seconds)

        timestr = "20051213141205+0500"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(5, time.tzinfo.houroffset)
        assert_equal(0, time.tzinfo.minoffset)
        offset = time.tzinfo.utcoffset(time.tzinfo.dst())
        assert_equal(5 * 60 * 60, offset.seconds)

        timestr = "20051213141205-0500"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(-5, time.tzinfo.houroffset)
        assert_equal(0, time.tzinfo.minoffset)
        # NOTE - the offset is always positive - it's minutes
        #        _east_ of UTC
        offset = time.tzinfo.utcoffset(time.tzinfo.dst())
        assert_equal((24 - 5) * 60 * 60, offset.seconds)

        timestr = "20051213141205-0930"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(-9, time.tzinfo.houroffset)
        assert_equal(-30, time.tzinfo.minoffset)
        offset = time.tzinfo.utcoffset(time.tzinfo.dst())
        assert_equal(((24 - 9) * 60 * 60) - (30 * 60), offset.seconds)
예제 #2
0
    def test_time_zones(self):
        timestr = "20051213141205Z"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(0, time.tzinfo.houroffset)
        nose.tools.assert_equal(0, time.tzinfo.minoffset)
        offset = time.tzinfo.utcoffset(time.tzinfo.dst())
        nose.tools.assert_equal(0, offset.seconds)

        timestr = "20051213141205+0500"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(5, time.tzinfo.houroffset)
        nose.tools.assert_equal(0, time.tzinfo.minoffset)
        offset = time.tzinfo.utcoffset(time.tzinfo.dst())
        nose.tools.assert_equal(5 * 60 * 60, offset.seconds)

        timestr = "20051213141205-0500"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(-5, time.tzinfo.houroffset)
        nose.tools.assert_equal(0, time.tzinfo.minoffset)
        # NOTE - the offset is always positive - it's minutes
        #        _east_ of UTC
        offset = time.tzinfo.utcoffset(time.tzinfo.dst())
        nose.tools.assert_equal((24 - 5) * 60 * 60, offset.seconds)

        timestr = "20051213141205-0930"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(-9, time.tzinfo.houroffset)
        nose.tools.assert_equal(-30, time.tzinfo.minoffset)
        offset = time.tzinfo.utcoffset(time.tzinfo.dst())
        nose.tools.assert_equal(((24 - 9) * 60 * 60) - (30 * 60), offset.seconds)
예제 #3
0
    def test_fractions(self):
        timestr = "2003092208.5"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(2003, time.year)
        assert_equal(9, time.month)
        assert_equal(22, time.day)
        assert_equal(8, time.hour)
        assert_equal(30, time.minute)
        assert_equal(0, time.second)

        timestr = "199203301544,25"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(1992, time.year)
        assert_equal(3, time.month)
        assert_equal(30, time.day)
        assert_equal(15, time.hour)
        assert_equal(44, time.minute)
        assert_equal(15, time.second)

        timestr = "20060401185912,8"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(2006, time.year)
        assert_equal(4, time.month)
        assert_equal(1, time.day)
        assert_equal(18, time.hour)
        assert_equal(59, time.minute)
        assert_equal(12, time.second)
        assert_equal(800000, time.microsecond)
예제 #4
0
    def test_fractions(self):
        timestr = "2003092208.5"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(2003, time.year)
        nose.tools.assert_equal(9, time.month)
        nose.tools.assert_equal(22, time.day)
        nose.tools.assert_equal(8, time.hour)
        nose.tools.assert_equal(30, time.minute)
        nose.tools.assert_equal(0, time.second)

        timestr = "199203301544,25"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(1992, time.year)
        nose.tools.assert_equal(3, time.month)
        nose.tools.assert_equal(30, time.day)
        nose.tools.assert_equal(15, time.hour)
        nose.tools.assert_equal(44, time.minute)
        nose.tools.assert_equal(15, time.second)

        timestr = "20060401185912,8"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(2006, time.year)
        nose.tools.assert_equal(4, time.month)
        nose.tools.assert_equal(1, time.day)
        nose.tools.assert_equal(18, time.hour)
        nose.tools.assert_equal(59, time.minute)
        nose.tools.assert_equal(12, time.second)
        nose.tools.assert_equal(800000, time.microsecond)
예제 #5
0
    def test_hour_min_sec(self):
        timestr = "20051213141205"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(2005, time.year)
        assert_equal(12, time.month)
        assert_equal(13, time.day)
        assert_equal(14, time.hour)
        assert_equal(12, time.minute)
        assert_equal(5, time.second)
예제 #6
0
    def test_simple(self):
        timestr = "20070803"

        time = ipautil.parse_generalized_time(timestr)
        assert_equal(2007, time.year)
        assert_equal(8, time.month)
        assert_equal(3, time.day)
        assert_equal(0, time.hour)
        assert_equal(0, time.minute)
        assert_equal(0, time.second)
예제 #7
0
    def test_hour_min_sec(self):
        timestr = "20051213141205"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(2005, time.year)
        nose.tools.assert_equal(12, time.month)
        nose.tools.assert_equal(13, time.day)
        nose.tools.assert_equal(14, time.hour)
        nose.tools.assert_equal(12, time.minute)
        nose.tools.assert_equal(5, time.second)
예제 #8
0
    def test_simple(self):
        timestr = "20070803"

        time = ipautil.parse_generalized_time(timestr)
        nose.tools.assert_equal(2007, time.year)
        nose.tools.assert_equal(8, time.month)
        nose.tools.assert_equal(3, time.day)
        nose.tools.assert_equal(0, time.hour)
        nose.tools.assert_equal(0, time.minute)
        nose.tools.assert_equal(0, time.second)
예제 #9
0
    def testHourMinSec(self):
        timestr = "20051213141205"

        time = ipautil.parse_generalized_time(timestr)
        self.assertEqual(2005, time.year)
        self.assertEqual(12, time.month)
        self.assertEqual(13, time.day)
        self.assertEqual(14, time.hour)
        self.assertEqual(12, time.minute)
        self.assertEqual(5, time.second)
예제 #10
0
    def testHourMinSec(self):
        timestr = "20051213141205"

        time = ipautil.parse_generalized_time(timestr)
        self.assertEqual(2005, time.year)
        self.assertEqual(12, time.month)
        self.assertEqual(13, time.day)
        self.assertEqual(14, time.hour)
        self.assertEqual(12, time.minute)
        self.assertEqual(5, time.second)
예제 #11
0
    def testSimple(self):
        timestr = "20070803"

        time = ipautil.parse_generalized_time(timestr)
        self.assertEqual(2007, time.year)
        self.assertEqual(8, time.month)
        self.assertEqual(3, time.day)
        self.assertEqual(0, time.hour)
        self.assertEqual(0, time.minute)
        self.assertEqual(0, time.second)
예제 #12
0
def print_replication_status(entry, verbose):
    """Pretty print nsds5replicalastinitstatus, nsds5replicalastinitend,
    nsds5replicalastupdatestatus, nsds5replicalastupdateend for a
    replication agreement.
    """

    if verbose:
        initstatus = entry.single_value.get('nsds5replicalastinitstatus')
        if initstatus is not None:
            print("  last init status: %s" % initstatus)
            print("  last init ended: %s" % str(
                ipautil.parse_generalized_time(
                    entry.single_value['nsds5replicalastinitend'])))
        updatestatus = entry.single_value.get(
            'nsds5replicalastupdatestatus'
        )
        if updatestatus is not None:
            print("  last update status: %s" % updatestatus)
            print("  last update ended: %s" % str(
                ipautil.parse_generalized_time(
                    entry.single_value['nsds5replicalastupdateend']
                ))
            )