Skip to content

Commit

Permalink
Minor painless fix (#1075)
Browse files Browse the repository at this point in the history
Actually, the data format could be different too. Fix it and add it to
test.
  • Loading branch information
jakozaur authored Dec 6, 2024
1 parent 95583aa commit 0a83503
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions quesma/painful/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions quesma/painful/model_test.go
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit 0a83503

Please sign in to comment.