-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_to_datetime.py
30 lines (22 loc) · 1.07 KB
/
test_to_datetime.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from datetime import datetime
import unittest
import kanji_to_time as ktt
class TestClass(unittest.TestCase):
def test_standard(self):
dt = ktt.to_datetime("2024年4月5日22時30分4秒")
self.assertEqual(
dt, datetime(year=2024, month=4, day=5, hour=22, minute=30, second=4)
)
dt = ktt.to_datetime("2020年5月7日")
self.assertEqual(dt, datetime(year=2020, month=5, day=7))
dt = ktt.to_datetime("二〇二五年十二月七日")
self.assertEqual(dt, datetime(year=2025, month=12, day=7))
dt = ktt.to_datetime("二千年八月三日")
self.assertEqual(dt, datetime(year=2000, month=8, day=3))
dt = ktt.to_datetime("弐零弐参年伍月肆日")
self.assertEqual(dt, datetime(year=2023, month=5, day=4))
def test_detail(self):
dt = ktt.to_datetime("2024年四月5日")
self.assertEqual(dt, datetime(year=2024, month=4, day=5))
dt = ktt.to_datetime("2024年4月5日")
self.assertEqual(dt, datetime(year=2024, month=4, day=5))