| 1 |
# vim:fileencoding=utf-8 |
| 2 |
# License: GPL v3 Copyright: 2020, Kovid Goyal <kovid at kovidgoyal.net> |
| 3 |
from __python__ import bound_methods, hash_literals |
| 4 |
|
| 5 |
from date import format_date, get_ampm_text |
| 6 |
from testing import test, assert_equal, assert_true |
| 7 |
|
| 8 |
|
| 9 |
def test_fd(date, fmt, ans): |
| 10 |
q = format_date(date, fmt, as_utc=True) |
| 11 |
assert_equal(ans, q) |
| 12 |
|
| 13 |
|
| 14 |
@test |
| 15 |
def date_formatting(): |
| 16 |
assert_true(get_ampm_text('am')) |
| 17 |
assert_true(get_ampm_text('pm')) |
| 18 |
test_fd('1101-01-01T09:00:00+00:00', 'hh h', '09 9') |
| 19 |
test_fd('1101-01-01T12:15:00+00:00', 'h:m ap', '12:15 pm') |
| 20 |
test_fd('1101-01-01T00:15:00+00:00', 'h:m ap', '12:15 am') |
| 21 |
test_fd('1101-01-01T13:15:00+00:00', 'h:m ap', '1:15 pm') |
| 22 |
test_fd('1101-01-01T09:01:00+00:00', 'h:mm AP', '9:01 AM') |
| 23 |
test_fd('1101-01-01T09:05:01.012+00:00', 'hh h mm m ss s z zzz ap AP a A yy yyyy', '09 9 05 5 01 1 12 012 am AM am AM 01 1101') |
| 24 |
test_fd('2001-01-02T09:00:00+00:00', 'M MM MMM MMMM', '1 01 Jan January') |
| 25 |
test_fd('2001-01-01T12:00:00+00:00', 'd dd ddd dddd', '1 01 Mon Monday') |
| 26 |
# test_fd('2001-01-01T12:00:00+05:30', 'd t', '1 India Standard Time') |