Skip to content

Implements the W3C datetime format for Golang

License

Notifications You must be signed in to change notification settings

bored-engineer/w3c-datetime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

w3c-datetime Go Reference

Implements the W3C datetime format for Golang.

package main

import (
	"fmt"

	datetime "github.com/bored-engineer/w3c-datetime"
)

func main() {
	d, err := datetime.Parse("1994-11-05")
	if err != nil {
		panic(err)
	}
	fmt.Println(d.Precision) // YYYY-MM-DD
    fmt.Println(d.Time) // 1994-11-05 00:00:00 +0000 UTC
 
	dt, err := datetime.Parse("1994-11-05T08:15:30Z")
	if err != nil {
		panic(err)
	}
	fmt.Println(dt.Precision) // YYYY-MM-DDThh:mm:ssTZD
    fmt.Println(dt.Time) // 1994-11-05 08:15:30 +0000 UTC
}

About

Implements the W3C datetime format for Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages