Example #1
0
def test_iso8601_datetime_formatters():
    dates = [(datetime(2011, 1, 1), "2011-01-01T00:00:00+00:00"),
             (datetime(2011, 1, 1, 23, 59, 59), "2011-01-01T23:59:59+00:00"),
             (datetime(2011, 1, 1, 23, 59, 59,
                       tzinfo=pytz.utc), "2011-01-01T23:59:59+00:00"),
             (datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.timezone('CET')),
              "2011-01-01T22:59:59+00:00")]
    for date_obj, expected in dates:
        yield assert_equals, fields._iso8601(date_obj), expected
Example #2
0
def test_iso8601_datetime_formatters():
    dates = [
        (datetime(2011, 1, 1), "2011-01-01T00:00:00"),
        (datetime(2011, 1, 1, 23, 59, 59), "2011-01-01T23:59:59"),
        (datetime(2011, 1, 1, 23, 59, 59, 1000), "2011-01-01T23:59:59.001000"),
        (datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.utc), "2011-01-01T23:59:59+00:00"),
        (datetime(2011, 1, 1, 23, 59, 59, 1000, tzinfo=pytz.utc), "2011-01-01T23:59:59.001000+00:00"),
        (datetime(2011, 1, 1, 23, 59, 59, tzinfo=pytz.timezone("CET")), "2011-01-01T23:59:59+01:00"),
    ]
    for date_obj, expected in dates:
        yield assert_equals, fields._iso8601(date_obj), expected