mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
minor: x/jsonx.ParseISO8601
more features designed for the past 2-3 months to come, this is just a hotfix
This commit is contained in:
@@ -75,6 +75,7 @@ func ParseISO8601(s string) (ISO8601, error) {
|
||||
err error
|
||||
)
|
||||
|
||||
/*
|
||||
// Check if the string contains a timezone offset after the 'T' character.
|
||||
hasOffset := strings.Contains(s, "Z") || (strings.Index(s, "+") > strings.Index(s, "T")) || (strings.Index(s, "-") > strings.Index(s, "T"))
|
||||
|
||||
@@ -94,8 +95,8 @@ func ParseISO8601(s string) (ISO8601, error) {
|
||||
}
|
||||
|
||||
return ISO8601(tt), nil
|
||||
*/
|
||||
|
||||
/*
|
||||
if idx := strings.LastIndexFunc(s, startUTCOffsetIndexFunc); idx > 18 { // should have some distance, with and without milliseconds
|
||||
length := parseSignedOffset(s[idx:])
|
||||
|
||||
@@ -117,17 +118,17 @@ func ParseISO8601(s string) (ISO8601, error) {
|
||||
if strings.Contains(s, ".") {
|
||||
tt, err = time.ParseInLocation(ISO8601ZUTCOffsetLayoutWithMicroseconds, s, loc)
|
||||
} else {
|
||||
tt, err = time.ParseInLocation(ISO8601ZUTCOffsetLayout, s, loc)
|
||||
tt, err = time.ParseInLocation(ISO8601ZUTCOffsetLayoutWithoutMicroseconds, s, loc)
|
||||
}
|
||||
} else { // Local or UTC.
|
||||
if strings.Contains(s, ".") {
|
||||
tt, err = time.Parse(ISO8601ZUTCOffsetLayoutWithMicroseconds, s)
|
||||
} else {
|
||||
tt, err = time.Parse(ISO8601ZUTCOffsetLayout, s)
|
||||
tt, err = time.Parse(ISO8601ZUTCOffsetLayoutWithoutMicroseconds, s)
|
||||
}
|
||||
}
|
||||
} else if s[len(s)-1] == 'Z' {
|
||||
tt, err = time.Parse(ISO8601ZLayout, s)
|
||||
tt, err = time.Parse(ISO8601LayoutWithTimezone, s)
|
||||
} else {
|
||||
tt, err = time.Parse(ISO8601Layout, s)
|
||||
}
|
||||
@@ -136,7 +137,6 @@ func ParseISO8601(s string) (ISO8601, error) {
|
||||
return ISO8601{}, fmt.Errorf("ISO8601: %w", err)
|
||||
}
|
||||
return ISO8601(tt), nil
|
||||
*/
|
||||
}
|
||||
|
||||
func parseWithOffset(s string) (time.Time, error) {
|
||||
|
||||
Reference in New Issue
Block a user