Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
97 lines (64 sloc) 3.28 KB


A tiny date object in Go. Tinydate uses 4 bytes of memory vs the 24 bytes of a standard time.Time{}

A tinydate only has day precision. It has no knowledge of hours, minutes, seconds, or timezones.

⚙️ Installation

go get

🚀 Quick Start

package main

import (
    tinydate ""

func main(){
    td, err := tinydate.New(2020, 04, 3)
	if err != nil {
    td = td.Add(time.Hour * 48)
    // prints 2020-04-05


If you don't have resource constraints, then don't use tinydate! Use the standard time pacakge.

go-tinydate works well in the following situations:

  • You are working in embedded systems where memory is a luxury
  • You are storing many dates and smaller memory footprint is desired
  • You are 101% sure you don't need more than date precision


I needed to store many thousands of dates in memory in order to keep track of which IDs I had seen in the last X number of days. As such, I had a giant map[int]time.Time. Switching from map[int]time.Time to map[int]tinydate.TinyDate reduced my program's memory from an average ~1GB to ~200MB.

💬 Contact

Twitter Follow

Submit an issue (above in the issues tab)



Tinydate mirrors the time.Time API for the most part. The following are the only methods on the time.Time object that are not included on the tinydate.TinyDate object, because they make no sense without more than day precision


All formatting is done via the time.Time package's formatting capabilites, but anything besides date data will be zeroed out for obvious reasons.

Transient Dependencies

None! And it will stay that way, except of course for the standard library.

Note: Currently the testify package is used only for testing, but that dependency will be removed in coming updates.

👏 Contributing

I love help! Contribute by forking the repo and opening pull requests. Please ensure that your code passes the existing tests and linting, and write tests to test your changes if applicable.

All pull requests should be submitted to the "master" branch.

go test
go fmt
You can’t perform that action at this time.