def test_tstamp2time(self):
        dt_from_ts = tstamp2time('2010-11-12T131415.000016')
        self.assertEqual(datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=16, tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T131415.000016')
        self.assertEqual(datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=16, tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T131415.000016Z')
        self.assertEqual(datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=16, tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('2010-11-12T131415')
        self.assertEqual(datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=0, tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('2010-11-12T13:14:15')
        self.assertEqual(datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=0, tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T13:14:15')
        self.assertEqual(datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=0, tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T13:14:15Z')
        self.assertEqual(datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=0, tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T13:14:15Z')
        self.assertEqual(datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=0, tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('2010-06-30T21:26:40.000Z')
        self.assertEqual(datetime(year=2010, month=06, day=30, hour=21, minute=26, second=40, microsecond=0, tzinfo=UTC()), dt_from_ts)
 def test_tstamp2time4(self):
     dt_from_ts = tstamp2time('2010-11-12T131415')
     assert dt_from_ts == datetime(year=2010,
                                   month=11,
                                   day=12,
                                   hour=13,
                                   minute=14,
                                   second=15,
                                   microsecond=0,
                                   tzinfo=UTC())
 def test_tstamp2time9(self):
     dt_from_ts = tstamp2time('2010-06-30T21:26:40.000Z')
     assert dt_from_ts == datetime(year=2010,
                                   month=6,
                                   day=30,
                                   hour=21,
                                   minute=26,
                                   second=40,
                                   microsecond=0,
                                   tzinfo=UTC())
Example #4
0
 def test_tstamp2time3(self):
     dt_from_ts = tstamp2time('20101112T131415.000016Z')
     assert datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=16,
                     tzinfo=UTC()) == dt_from_ts
 def test_time2tstamp_tstamp2time_is_idempotent(self):
     dt = datetime.utcnow()
     ts = time2tstamp(dt)
     dt_from_ts = tstamp2time(ts)
     assert dt == dt_from_ts
Example #6
0
    def test_tstamp2time(self):
        dt_from_ts = tstamp2time('2010-11-12T131415.000016')
        self.assertEqual(
            datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=16,
                     tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T131415.000016')
        self.assertEqual(
            datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=16,
                     tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T131415.000016Z')
        self.assertEqual(
            datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=16,
                     tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('2010-11-12T131415')
        self.assertEqual(
            datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=0,
                     tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('2010-11-12T13:14:15')
        self.assertEqual(
            datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=0,
                     tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T13:14:15')
        self.assertEqual(
            datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=0,
                     tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T13:14:15Z')
        self.assertEqual(
            datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=0,
                     tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('20101112T13:14:15Z')
        self.assertEqual(
            datetime(year=2010,
                     month=11,
                     day=12,
                     hour=13,
                     minute=14,
                     second=15,
                     microsecond=0,
                     tzinfo=UTC()), dt_from_ts)

        dt_from_ts = tstamp2time('2010-06-30T21:26:40.000Z')
        self.assertEqual(
            datetime(year=2010,
                     month=06,
                     day=30,
                     hour=21,
                     minute=26,
                     second=40,
                     microsecond=0,
                     tzinfo=UTC()), dt_from_ts)
 def test_tstamp2time9(self):
     dt_from_ts = tstamp2time('2010-06-30T21:26:40.000Z')
     assert dt_from_ts == datetime(year=2010, month=06, day=30, hour=21, minute=26, second=40, microsecond=0, tzinfo=UTC())
 def test_tstamp2time8(self):
     dt_from_ts = tstamp2time('20101112T13:14:15Z')
     assert dt_from_ts == datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=0, tzinfo=UTC())
 def test_tstamp2time(self):
     dt_from_ts = tstamp2time('2010-11-12T131415.000016')
     assert dt_from_ts == datetime(year=2010, month=11, day=12, hour=13, minute=14, second=15, microsecond=16, tzinfo=UTC())
 def test_time2tstamp_tstamp2time_is_idempotent(self):
     dt = datetime.utcnow()
     ts = time2tstamp(dt)
     dt_from_ts = tstamp2time(ts)
     assert dt == dt_from_ts