Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 0a83503

Browse files
authored
Minor painless fix (#1075)
Actually, the data format could be different too. Fix it and add it to test.
1 parent 95583aa commit 0a83503

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

quesma/painful/model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ func ExpectDate(potentialExpr any) (time.Time, error) {
234234
formats := []string{
235235
"Jan 2, 2006 @ 15:04:05.000 -0700 MST", // this format in example provided by Kibana\
236236
"2006-01-02 15:04:05.000 -0700 MST", // clickhouse format
237+
"2006-01-02 15:04:05 -0700 MST", // early adopter format
237238
time.Layout,
238239
time.ANSIC,
239240
time.UnixDate,

quesma/painful/model_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright Quesma, licensed under the Elastic License 2.0.
2+
// SPDX-License-Identifier: Elastic-2.0
3+
package painful
4+
5+
import (
6+
"github.com/stretchr/testify/assert"
7+
"testing"
8+
"time"
9+
)
10+
11+
func TestExpectDate(t *testing.T) {
12+
expectedLocation := time.FixedZone("CEST", 2*60*60) // +0200 offset
13+
res, e := ExpectDate("2024-10-16 13:43:40 +0200 CEST")
14+
assert.NoError(t, e)
15+
res = res.In(expectedLocation)
16+
assert.Equal(t, res, time.Date(2024, 10, 16, 13, 43, 40, 0, expectedLocation))
17+
}

0 commit comments

Comments
 (0)