forked from furnace-dev/furnace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_small_time.mojo
More file actions
33 lines (24 loc) · 921 Bytes
/
test_small_time.mojo
File metadata and controls
33 lines (24 loc) · 921 Bytes
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
31
32
33
from testing import assert_equal, assert_true
from small_time.small_time import from_timestamp, now
fn test_small_time_yymmdd() raises:
# expiry = 1593763200000
# print(yymmdd(1717392000, ""))
# 2020-07-03 16:00:00
var p1 = from_timestamp(1593763200000)
if "08:00" in str(p1):
assert_equal(str(p1), "2020-07-03T16:00:00.000000+08:00")
assert_equal(p1.format("YYMMDD"), "200703")
var p2 = from_timestamp(1593763200)
assert_equal(p2.format("YYMMDD"), "200703")
fn test_small_time_iso8601() raises:
var p1 = from_timestamp(1593763200000)
if "08:00" in p1.isoformat():
assert_equal(p1.isoformat(), "2020-07-03T16:00:00.000000+08:00")
fn test_now() raises:
var p1 = now()
var s = p1.format("YYYY-MM-DD HH:mm:ss.SSS")
assert_true("20" in s)
fn main() raises:
var t = now(utc=False)
var s = t.format("YYYY-MM-DD HH:mm:ss.SSSSSS")
print(s)