Skip to content

Commit 6b48a5c

Browse files
committed
mktime/0: remove unnecessary length>=6 input requirement
This check was redundant and useless since jv2tm() used to require 8 elements, and errored anyway if not enough elements were provided. After commit bc96146, this check also prevents mktime/0 from accepting now supported inputs with less than 8 elements. Ref: jqlang#3070 (comment) Reported-by: itchyny <[email protected]>
1 parent 137018d commit 6b48a5c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/builtin.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,6 @@ static int jv2tm(jv a, struct tm *tm) {
15601560
static jv f_mktime(jq_state *jq, jv a) {
15611561
if (jv_get_kind(a) != JV_KIND_ARRAY)
15621562
return ret_error(a, jv_string("mktime requires array inputs"));
1563-
if (jv_array_length(jv_copy(a)) < 6)
1564-
return ret_error(a, jv_string("mktime requires parsed datetime inputs"));
15651563
struct tm tm;
15661564
if (!jv2tm(a, &tm))
15671565
return jv_invalid_with_msg(jv_string("mktime requires parsed datetime inputs"));

tests/jq.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,10 @@ strftime("%Y-%m-%dT%H:%M:%SZ")
15921592
[2024,2,15]
15931593
"2024-03-15T00:00:00Z"
15941594

1595+
mktime
1596+
[2024,8,21]
1597+
1726876800
1598+
15951599
gmtime
15961600
1425599507
15971601
[2015,2,5,23,51,47,4,63]

0 commit comments

Comments
 (0)