Skip to content

tomaspavlic/date

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

date.Date

Tests GitHub go.mod Go version Go Reference GitHub

Represents dates with values from January 1, 0001 Anno Domini (Common Era) through December 31, 9999 A.D (C.E) in Gregorian calendar. date.Date represents number of days since January 1, 001.

Installation

date.Date is compatible with modern Go releases in module mode, with Go installed:

go get github.com/tomaspavlic/date

date.Date vs time.Time

time.Time consists of wall and ext encode the wall time seconds, wall time nanoseconds, and optional monotonic clock reading in nanoseconds. time.Time also contains time.Location. The overall size of the struct is 24 bytes. Working in date.Date is reduced to just be just single int64 therefore 1/3 of time.Time size.

Usage

import "github.com/tomaspavlic/date"
// Create date.Date by just year, month and day
someDate := date.Create(2000, 1, 1)
// `date.Date` has similar functions as build-in `time.Time`
numberOfDays := date.Since(someDate)
fmt.Println("Number of days since 2000-01-01:", numberOfDays)

More

Documentation can be found on pkg.go.dev.

License

This library is distributed under the MIT license found in the LICENSE file.