From a72a368fb41cd499082a6d777bf4182560249734 Mon Sep 17 00:00:00 2001 From: Emanuele Torre Date: Wed, 21 Aug 2024 01:35:36 +0200 Subject: [PATCH] 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 supported0 inputs with less than 8 elements. Ref: https://github.com/jqlang/jq/pull/3070#issuecomment-2299902072 Reported-by: itchyny --- src/builtin.c | 2 -- tests/jq.test | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/builtin.c b/src/builtin.c index e39975b0a0..f55727eecc 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -1560,8 +1560,6 @@ static int jv2tm(jv a, struct tm *tm) { static jv f_mktime(jq_state *jq, jv a) { if (jv_get_kind(a) != JV_KIND_ARRAY) return ret_error(a, jv_string("mktime requires array inputs")); - if (jv_array_length(jv_copy(a)) < 6) - return ret_error(a, jv_string("mktime requires parsed datetime inputs")); struct tm tm; if (!jv2tm(a, &tm)) return jv_invalid_with_msg(jv_string("mktime requires parsed datetime inputs")); diff --git a/tests/jq.test b/tests/jq.test index 1502fbe058..8c566f87f7 100644 --- a/tests/jq.test +++ b/tests/jq.test @@ -1592,6 +1592,10 @@ strftime("%Y-%m-%dT%H:%M:%SZ") [2024,2,15] "2024-03-15T00:00:00Z" +mktime +[2024,8,21] +1726876800 + gmtime 1425599507 [2015,2,5,23,51,47,4,63]