relvacode / iso8601

A fast ISO8601 date parser for Go
MIT License
144 stars 16 forks source link

Timezone of "-00" and "-00:00" should be invalid per ISO8601 3.4.2 #7

Closed gavbaa closed 4 years ago

gavbaa commented 4 years ago

Wikipedia's breakdown of ISO8601 Section 3.4.2:

An offset of zero, in addition to having the special representation "Z", can also be stated numerically as "+00:00", "+0000", or "+00". However, it is not permitted to state it numerically with a negative sign, as "−00:00", "−0000", or "−00". The section dictating sign usage (section 3.4.2 in the 2004 edition of the standard) states that a plus sign must be used for a positive or zero value, and a minus sign for a negative value. Contrary to this rule, RFC 3339, which is otherwise a profile of ISO 8601, permits the use of "-00", with the same denotation as "+00" but a differing connotation.

package main

import (
    "github.com/relvacode/iso8601"
    "github.com/davecgh/go-spew/spew"
)

func main() {
    t, err := iso8601.ParseString("2020-01-02T16:20:00.999-00")
    spew.Dump(t, err)
}

Outputs

(time.Time) 2020-01-02 16:20:00.999 +0000 +0000
(interface {}) <nil>

when it should be outputting an error.