Beispiel #1
0
 def test_from_datetime_aware_with_change(self):
     tz = [tzlocal(), self.utc, self.jst, self.pst]
     for tz1, tz2 in ((tz1, tz2) for tz1 in tz for tz2 in tz):
         dt = datetime(2000, 12, 31, 4, 56, 7, 890, tz1)
         rtd = RichDateTime.from_datetime(dt, tz2)
         self.assertEqual(rtd, dt)
         self.assertEqual(rtd.tzinfo, tz2)
Beispiel #2
0
 def test_from_datetime_aware_without_change(self):
     for tz in [tzlocal(), self.utc, self.jst, self.pst]:
         dt = datetime(2000, 12, 31, 4, 56, 7, 890, tz)
         rtd = RichDateTime.from_datetime(dt)
         self.assertEqual(rtd, dt)
         self.assertEqual(rtd.tzinfo, tz)
Beispiel #3
0
 def test_from_datetime_naive_to_specified_timezone(self):
     dt = datetime(2000, 12, 31, 4, 56, 7, 890)
     self.assertEqual(RichDateTime.from_datetime(dt, self.jst), datetime(2000, 12, 31, 4, 56, 7, 890, self.jst))
     self.assertEqual(RichDateTime.from_datetime(dt, self.pst), datetime(2000, 12, 31, 4, 56, 7, 890, self.pst))
Beispiel #4
0
 def test_from_datetime_naive_to_utc(self):
     dt = datetime(2000, 12, 31, 4, 56, 7, 890)
     self.assertEqual(RichDateTime.from_datetime(dt, self.utc), datetime(2000, 12, 31, 4, 56, 7, 890, self.utc))
Beispiel #5
0
 def test_from_datetime_naive_to_local(self):
     dt = datetime(2000, 12, 31, 4, 56, 7, 890)
     self.assertEqual(RichDateTime.from_datetime(dt, tzlocal()), datetime(2000, 12, 31, 4, 56, 7, 890, tzlocal()))
Beispiel #6
0
 def test_from_datetime_naive_to_naive(self):
     dt = datetime(2000, 12, 31, 4, 56, 7, 890)
     self.assertRaises(ValueError, lambda: RichDateTime.from_datetime(dt))