Skip to content

Commit

Permalink
improve tests for date-time functions
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Mar 2, 2025
1 parent f4c2cfe commit 05329e2
Showing 1 changed file with 40 additions and 35 deletions.
75 changes: 40 additions & 35 deletions cli/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5531,57 +5531,62 @@
- name: gmtime, localtime functions
args:
- -c
- 'gmtime, localtime'
- 'gmtime, localtime | map(. * 1000000 | floor / 1000000)'
input: '1500000000 1567890123.456 1600000000.111'
expected: | # tested with UTC-7
expected: | # UTC-7 (TZ=Etc/GMT+7)
[2017,6,14,2,40,0,5,194]
[2017,6,13,19,40,0,4,193]
[2019,8,7,21,2,3.4560000889999998,6,249]
[2019,8,7,14,2,3.4560000889999998,6,249]
[2020,8,13,12,26,40.111000061,0,256]
[2020,8,13,5,26,40.111000061,0,256]
[2019,8,7,21,2,3.456,6,249]
[2019,8,7,14,2,3.456,6,249]
[2020,8,13,12,26,40.111,0,256]
[2020,8,13,5,26,40.111,0,256]
- name: mktime, strftime, strflocaltime, todate functions
args:
- -c
- 'mktime, ((.,mktime) | strftime("%Y-%m-%dT%H:%M:%SZ")), ((.,mktime) | strflocaltime("%Y-%m-%dT%H:%M:%S%z")), todate'
- -cr
- '(.,mktime | .,strftime("%Y-%m-%dT%H:%M:%SZ"),strflocaltime("%Y-%m-%dT%H:%M:%S%z")), todate'
input: |
[2017,6,14,2,40,0,5,194]
[2019,8,7,21,2,3.4560000889999998,6,249]
[2020,8,13,12,26,40.111000061,0,256]
[2019,8,7,21,2,3.456,6,249]
[2020,8,13,12,26,40.111,0,256]
[2024,7,20]
[2025]
expected: |
[2017,6,14,2,40,0,5,194]
2017-07-14T02:40:00Z
2017-07-14T02:40:00-0700
1500000000
"2017-07-14T02:40:00Z"
"2017-07-14T02:40:00Z"
"2017-07-14T02:40:00-0700"
"2017-07-13T19:40:00-0700"
"2017-07-14T02:40:00Z"
2017-07-14T02:40:00Z
2017-07-13T19:40:00-0700
2017-07-14T02:40:00Z
[2019,8,7,21,2,3.456,6,249]
2019-09-07T21:02:03Z
2019-09-07T21:02:03-0700
1567890123.456
"2019-09-07T21:02:03Z"
"2019-09-07T21:02:03Z"
"2019-09-07T21:02:03-0700"
"2019-09-07T14:02:03-0700"
"2019-09-07T21:02:03Z"
2019-09-07T21:02:03Z
2019-09-07T14:02:03-0700
2019-09-07T21:02:03Z
[2020,8,13,12,26,40.111,0,256]
2020-09-13T12:26:40Z
2020-09-13T12:26:40-0700
1600000000.111
"2020-09-13T12:26:40Z"
"2020-09-13T12:26:40Z"
"2020-09-13T12:26:40-0700"
"2020-09-13T05:26:40-0700"
"2020-09-13T12:26:40Z"
2020-09-13T12:26:40Z
2020-09-13T05:26:40-0700
2020-09-13T12:26:40Z
[2024,7,20]
2024-08-20T00:00:00Z
2024-08-20T00:00:00-0700
1724112000
"2024-08-20T00:00:00Z"
"2024-08-20T00:00:00Z"
"2024-08-20T00:00:00-0700"
"2024-08-19T17:00:00-0700"
"2024-08-20T00:00:00Z"
2024-08-20T00:00:00Z
2024-08-19T17:00:00-0700
2024-08-20T00:00:00Z
[2025]
2024-12-31T00:00:00Z
2024-12-31T00:00:00-0700
1735603200
"2024-12-31T00:00:00Z"
"2024-12-31T00:00:00Z"
"2024-12-31T00:00:00-0700"
"2024-12-30T17:00:00-0700"
"2024-12-31T00:00:00Z"
2024-12-31T00:00:00Z
2024-12-30T17:00:00-0700
2024-12-31T00:00:00Z
- name: strptime, fromdate functions
args:
Expand Down

0 comments on commit 05329e2

Please sign in to comment.