xmldatetime

package module
v0.0.0-...-2292f08 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2017 License: MIT Imports: 8 Imported by: 2

README

xmldatetime - xml compatible dateTime

Simple implementation of xml dateTime format for use with build-in encoding/xml.

It conforms the XML spec: https://www.w3.org/TR/xmlschema-2/#dateTime

Install:

go get github.com/datainq/xml-date-time

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(s string) (time.Time, error)

Parses implements https://www.w3.org/TR/xmlschema-2 # 3.2.7.1 Lexical representation (dateTime) '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)? (('+' | '-') hh ':' mm) | 'Z' It's worth to mention that this is the fastest implementation of parser:

$go test -bench .
BenchmarkParse-4      	 5000000	       335 ns/op
BenchmarkParseRe-4    	 1000000	      1715 ns/op
BenchmarkParseRe2-4   	 1000000	      1686 ns/op
PASS
ok  	doz.pl/companions/data	6.298s

func ParseRe

func ParseRe(s string) (time.Time, error)

func ParseRe2

func ParseRe2(s string) (time.Time, error)

Types

type CustomTime

type CustomTime struct {
	time.Time
}

func (*CustomTime) MarshalXML

func (c *CustomTime) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*CustomTime) UnmarshalXML

func (c *CustomTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL