Skip to content

Commit da2a0b9

Browse files
authored
mktime/0: remove unnecessary length>=6 input requirement (#3162)
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: #3070 (comment) Reported-by: itchyny <[email protected]>
1 parent 0e0cdd5 commit da2a0b9

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
@@ -1602,8 +1602,6 @@ static int jv2tm(jv a, struct tm *tm) {
16021602
static jv f_mktime(jq_state *jq, jv a) {
16031603
if (jv_get_kind(a) != JV_KIND_ARRAY)
16041604
return ret_error(a, jv_string("mktime requires array inputs"));
1605-
if (jv_array_length(jv_copy(a)) < 6)
1606-
return ret_error(a, jv_string("mktime requires parsed datetime inputs"));
16071605
struct tm tm;
16081606
if (!jv2tm(a, &tm))
16091607
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
@@ -1610,6 +1610,10 @@ strftime("%Y-%m-%dT%H:%M:%SZ")
16101610
[2024,2,15]
16111611
"2024-03-15T00:00:00Z"
16121612

1613+
mktime
1614+
[2024,8,21]
1615+
1726876800
1616+
16131617
gmtime
16141618
1425599507
16151619
[2015,2,5,23,51,47,4,63]

0 commit comments

Comments
 (0)