Add LocalTime to interface{} decode support (#567)
Co-authored-by: Thomas Pelletier <thomas@pelletier.codes>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user