Commit e7546450 authored by Paul Warren's avatar Paul Warren
Browse files

xsd:date unmarshaller.

parent b7a49223
package xsd
/*
* Wrapper around time.Time that can be unmarshalled from an xsd:date value (YYYY-MM-DD)
*
* https://www.w3.org/TR/xmlschema-2/#date
*
* Does not currently allow the optional timezone component.
*/
import (
"code.blinkace.com/go/xml/encoding/xml"
"time"
)
type Date struct {
time.Time
}
func (date *Date) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var s string
d.DecodeElement(&s, &start)
var err error
date.Time, err = time.Parse("2006-01-02", s)
return err
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment