Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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()))
Exemplo n.º 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))