Add LocalTime to interface{} decode support (#567)

Co-authored-by: Thomas Pelletier <thomas@pelletier.codes>
This commit is contained in:
kkHAIKE
2021-07-21 23:50:12 +08:00
committed by GitHub
parent a93b34d984
commit 8be357dfa1
6 changed files with 146 additions and 6 deletions
+9 -3
View File
@@ -862,6 +862,7 @@ func digitsToInt(b []byte) int {
func (p *parser) scanDateTime(b []byte) (ast.Reference, []byte, error) {
// scans for contiguous characters in [0-9T:Z.+-], and up to one space if
// followed by a digit.
hasDate := false
hasTime := false
hasTz := false
seenSpace := false
@@ -874,6 +875,7 @@ byteLoop:
switch {
case isDigit(c):
case c == '-':
hasDate = true
const minOffsetOfTz = 8
if i >= minOffsetOfTz {
hasTz = true
@@ -898,10 +900,14 @@ byteLoop:
var kind ast.Kind
if hasTime {
if hasTz {
kind = ast.DateTime
if hasDate {
if hasTz {
kind = ast.DateTime
} else {
kind = ast.LocalDateTime
}
} else {
kind = ast.LocalDateTime
kind = ast.LocalTime
}
} else {
kind = ast.LocalDate