Exemplo n.º 1
0
 def test_today_timezone(self, mock_now):
     """Values are normalized to local time correctly."""
     d = datetime.datetime(2012, 1, 2, 23, 10, tzinfo=denver)
     with timezone.override(denver):
         assert serializers.naturaldatetime(d) == u"11:10pm"
     with timezone.override(timezone.utc):
         assert serializers.naturaldatetime(d) == u"6:10am"
Exemplo n.º 2
0
 def test_today_timezone(self, mock_now):
     """Values are normalized to local time correctly."""
     d = datetime.datetime(2012, 1, 2, 23, 10, tzinfo=denver)
     with timezone.override(denver):
         assert serializers.naturaldatetime(d) == u"11:10pm"
     with timezone.override(timezone.utc):
         assert serializers.naturaldatetime(d) == u"6:10am"
Exemplo n.º 3
0
 def test_timezone_naive(self, mock_now):
     """A naive datetime is assumed to be local time."""
     d = datetime.datetime(2012, 1, 15, 10, 34)
     with timezone.override(denver):
         assert serializers.naturaldatetime(d) == u"Jan 15 2012, 10:34am"
Exemplo n.º 4
0
 def test_different_year(self, mock_now):
     """A date in a different year is date and time with year."""
     d = datetime.datetime(2012, 1, 15, 10, 34, tzinfo=timezone.utc)
     assert serializers.naturaldatetime(d) == u"Jan 15 2012, 10:34am"
Exemplo n.º 5
0
 def test_same_year(self, mock_now):
     """A date within the current year is date and time without year."""
     d = datetime.datetime(2013, 1, 15, 8, 12, tzinfo=timezone.utc)
     assert serializers.naturaldatetime(d) == u"Jan 15, 8:12am"
Exemplo n.º 6
0
 def test_day_of_week(self, mock_now):
     """A date within the past week is rendered as weekday and time."""
     d = datetime.datetime(2013, 2, 5, 15, 45, tzinfo=timezone.utc)
     assert serializers.naturaldatetime(d) == u"Tue 3:45pm"
Exemplo n.º 7
0
 def test_today(self, mock_now):
     """A date today is rendered as just the time."""
     d = datetime.datetime(2012, 1, 3, 8, 23, tzinfo=timezone.utc)
     assert serializers.naturaldatetime(d) == u"8:23am"
Exemplo n.º 8
0
 def test_timezone_naive(self, mock_now):
     """A naive datetime is assumed to be local time."""
     d = datetime.datetime(2012, 1, 15, 10, 34)
     with timezone.override(denver):
         assert serializers.naturaldatetime(d) == u"Jan 15 2012, 10:34am"
Exemplo n.º 9
0
 def test_different_year(self, mock_now):
     """A date in a different year is date and time with year."""
     d = datetime.datetime(2012, 1, 15, 10, 34, tzinfo=timezone.utc)
     assert serializers.naturaldatetime(d) == u"Jan 15 2012, 10:34am"
Exemplo n.º 10
0
 def test_same_year(self, mock_now):
     """A date within the current year is date and time without year."""
     d = datetime.datetime(2013, 1, 15, 8, 12, tzinfo=timezone.utc)
     assert serializers.naturaldatetime(d) == u"Jan 15, 8:12am"
Exemplo n.º 11
0
 def test_day_of_week(self, mock_now):
     """A date within the past week is rendered as weekday and time."""
     d = datetime.datetime(2013, 2, 5, 15, 45, tzinfo=timezone.utc)
     assert serializers.naturaldatetime(d) == u"Tue 3:45pm"
Exemplo n.º 12
0
 def test_today(self, mock_now):
     """A date today is rendered as just the time."""
     d = datetime.datetime(2012, 1, 3, 8, 23, tzinfo=timezone.utc)
     assert serializers.naturaldatetime(d) == u"8:23am"