Skip to content

aodin/date

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

date GoDoc

Golang's missing date package, including ranges

Date builds on Golang's time.Time package to provide a ISO 8601 Date type

Create a new Date:

import "github.com/aodin/date"

func main() {
    march1st := date.New(2015, 3, 1)
    fmt.Println(march1st) // 2015-03-01
}

Parse a date or build it from a time:

date.Parse("2015-03-01")
date.FromTime(time.Now())

Ranges, including Union and Intersection operations:

date.NewRange(date.Today(), date.Today().AddDays(7))
date.EntireYear(2014).Union(date.EntireYear(2015))

By default, the Date type uses the time.UTC location. It can be passed to functions requiring the time.Time type using the embedded Time field:

jan1 := time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC)
jan1.Before(march1.Time)

Happy Hacking!

aodin, 2015-2016

About

Golang's missing date package, including ranges

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages