diff --git a/quesma/painful/model.go b/quesma/painful/model.go index c4224201e..0d816b485 100644 --- a/quesma/painful/model.go +++ b/quesma/painful/model.go @@ -234,6 +234,7 @@ func ExpectDate(potentialExpr any) (time.Time, error) { formats := []string{ "Jan 2, 2006 @ 15:04:05.000 -0700 MST", // this format in example provided by Kibana\ "2006-01-02 15:04:05.000 -0700 MST", // clickhouse format + "2006-01-02 15:04:05 -0700 MST", // early adopter format time.Layout, time.ANSIC, time.UnixDate, diff --git a/quesma/painful/model_test.go b/quesma/painful/model_test.go new file mode 100644 index 000000000..acd1402f9 --- /dev/null +++ b/quesma/painful/model_test.go @@ -0,0 +1,17 @@ +// Copyright Quesma, licensed under the Elastic License 2.0. +// SPDX-License-Identifier: Elastic-2.0 +package painful + +import ( + "github.com/stretchr/testify/assert" + "testing" + "time" +) + +func TestExpectDate(t *testing.T) { + expectedLocation := time.FixedZone("CEST", 2*60*60) // +0200 offset + res, e := ExpectDate("2024-10-16 13:43:40 +0200 CEST") + assert.NoError(t, e) + res = res.In(expectedLocation) + assert.Equal(t, res, time.Date(2024, 10, 16, 13, 43, 40, 0, expectedLocation)) +}