Skip to content

Commit

Permalink
[Date] Base date used when parsing is start of unix time, not 0001-01…
Browse files Browse the repository at this point in the history
…-01 (#143)

* [Date] Base date used when parsing is start of unix time, not 0001-01-01

* lint
  • Loading branch information
ohaibbq authored Jan 30, 2024
1 parent 5daac43 commit 7b48c5e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/function_time_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,9 @@ func parseTimeFormat(formatStr, targetStr string, typ TimeFormatType) (*time.Tim
targetIdx int
formatIdx int
)
ret := &time.Time{}
epoch := time.Unix(0, 0)
var ret = &epoch

for formatIdx < len(format) {
c := format[formatIdx]
if c == '%' {
Expand Down
6 changes: 6 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3640,6 +3640,12 @@ WITH example AS (
{now.Format("2006-01-02")},
},
},
{
name: "base date is epoch",
query: `SELECT PARSE_DATE("%m", "03")`,
expectedRows: [][]interface{}{
{"1970-03-01"},
}},
{
name: "extract date",
query: `
Expand Down

0 comments on commit 7b48c5e

Please sign in to comment.