From edda2b424fb6baceeda4560f2a7587c2d8d24eb4 Mon Sep 17 00:00:00 2001 From: Marc Worrell Date: Mon, 17 Jul 2023 10:27:34 +0200 Subject: [PATCH] mod_ginger_collection: fix filter on dates before the year 1000 (#733) --- modules/mod_ginger_collection/support/collection_query.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/mod_ginger_collection/support/collection_query.erl b/modules/mod_ginger_collection/support/collection_query.erl index f30d9883..ab0cb00f 100644 --- a/modules/mod_ginger_collection/support/collection_query.erl +++ b/modules/mod_ginger_collection/support/collection_query.erl @@ -168,10 +168,12 @@ map_related_to_property(#triple{}, QueryArgs) -> date_filter(_Key, _Operator, <<>>, _IncludeMissing) -> []; -date_filter(Key, Operator, Value, IncludeMissing) when Operator =:= <<"gte">>; Operator =:= <<"gt">>; +date_filter(Key, Operator, Value, IncludeMissing) when + Operator =:= <<"gte">>; Operator =:= <<"gt">>; Operator =:= <<"lte">>; Operator =:= <<"lt">> -> - DateFilter = [Key, Operator, Value, [{<<"format">>, <<"yyyy">>}]], + % Use "year", as "yyyy" is strict and gives an exception on years < 1000. + DateFilter = [Key, Operator, Value, [{<<"format">>, <<"year">>}]], OrFilters = case IncludeMissing of true -> [DateFilter, [Key, missing]];