Go's missing DateTime package

dt

Go's missing DateTime package

Build Status codecov Go Report Card

Why dt?

Go's standard library contains a single date package - time. The type provided by it, Time, contains date, time and location information.

More often than not we don't need location info, or we need to represent date/time only.

dt provides exactly that, a time-zone-independent representation of time that follows the rules of the proleptic Gregorian calendar with exactly 24-hour days, 60-minute hours, and 60-second minutes.

What is provided?

dt provides three types to work with:

  • Time: Contains time info: HH:mm
  • Date: Contains date info: YYYY-MM-DD
  • DateTime: Contains date and time information: YYYY-MM-DDTHH:mm

Unlike time.Time these types contain an additional Valid field representing whether the data inside it was scanned/marshaled. This prevents situations like saving default date in a database when nothing was received or responding via JSON with default date even though the date was empty.

Types provided in dt represent sql types time, date and timestamp.

Why not civil package?

Google already offers something similar in civil package.

  • It's not an independent library, but a small package in a very big project which leads to its problems.
  • It doesn't implement the Scan/Value SQL interfaces.
  • It marshalls to zero date/time/datetime (time.Time does this as well.) You can't differentiate inputted zero date/time/datetime and empty value.
  • Slower development cycle

License

dt is licensed under the Apache2 license. Check the LICENSE file for details.

Author

Emir Ribic

Owner
Similar Resources

The missing package manager for golang binaries (its homebrew for "go install")

Bingo: The missing package manager for golang binaries (its homebrew for "go install") Do you love the simplicity of being able to download & compile

Oct 31, 2022

Errr - Errr (The Rich Structured Error Package missing from Go)

The errr package was created to fill the gap between error handling and error reporting.

Feb 7, 2022

All the missing AMD64 atomic instructions

atomics All the AMD64 atomic instructions, exposed as Go functions: ⚠️ PRE-ALPHA ⚠️ Features LOCK {ADD,ADC,AND,BTC,BTR,BTS,CMPXCHG,CMPXCH8B,CMPXCHG16B

Sep 20, 2021

DNSTake — A fast tool to check missing hosted DNS zones that can lead to subdomain takeover

DNSTake — A fast tool to check missing hosted DNS zones that can lead to subdomain takeover

DNSTake — A fast tool to check missing hosted DNS zones that can lead to subdomain takeover

Dec 28, 2022

Analyse binaries for missing security features, information disclosure and more.

Analyse binaries for missing security features, information disclosure and more.

extrude Analyse binaries for missing security features, information disclosure and more. 🚧 Extrude is in the early stages of development, and current

Dec 16, 2022

Spriting that sass has been missing

Wellington Wellington adds spriting to the lightning fast libsass. No need to learn a new tool, this all happens right in your Sass! OS Support Binari

Nov 20, 2022

Domo is a Discord bot to help you manage your FOMO (fear of missing out).

domo domo is a Discord bot to help you manage your FOMO (fear of missing out). Development Download and install Go: Instructions To run the bot first

Jan 4, 2022

The missing git branch --interactive

git branch-i I got cross that there's no git branch --interactive, so I made this. It's a very (very) simple curses-mode git branch/git checkout alter

Nov 2, 2022

Go program that fetches urls and prepends http:// if missing

fetchautoprefix This is an exercise of the book The Go Programming Language, by

Dec 18, 2021

A command line tool for filling missing metric values on Mackerel.

mackerel-null-bridge A command line tool for filling missing metric values on Mackerel. Description When sending error metrics, etc., you may be force

Jan 11, 2022

Generic types that are missing from Go, including sets, trees, sorted lists, etc.

go-typ Generic types that are missing from Go, including sets, trees, sorted lists, etc. All code is implemented with 0 dependencies and in pure Go co

Dec 4, 2022

A Go (golang) package that enhances the standard database/sql package by providing powerful data retrieval methods as well as DB-agnostic query building capabilities.

ozzo-dbx Summary Description Requirements Installation Supported Databases Getting Started Connecting to Database Executing Queries Binding Parameters

Dec 31, 2022

Go Package Manager (gopm) is a package manager and build tool for Go.

🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 🚨 In favor of Go Modules Proxy since Go 1.11, this pr

Dec 14, 2022

Package set is a small wrapper around the official reflect package that facilitates loose type conversion and assignment into native Go types.

Package set is a small wrapper around the official reflect package that facilitates loose type conversion and assignment into native Go types. Read th

Dec 27, 2022

Go package providing simple database and server interfaces for the CSV files produced by the sfomuseum/go-libraryofcongress package

Go package providing simple database and server interfaces for the CSV files produced by the sfomuseum/go-libraryofcongress package

go-libraryofcongress-database Go package providing simple database and server interfaces for the CSV files produced by the sfomuseum/go-libraryofcongr

Oct 29, 2021

A package for running subprocesses in Go, similar to Python's subprocesses package.

A package for running subprocesses in Go, similar to Python's subprocesses package.

Jul 28, 2022

Utility to restrict which package is allowed to import another package.

go-import-rules Utility to restrict which package is allowed to import another package. This tool will read import-rules.yaml or import-rules.yml in t

Jan 7, 2022

A package for running subprocesses in Go, similar to Python's subprocesses package.

Subprocesses Spawn subprocesses in Go. Sanitized mode package main import ( "log" "github.com/estebangarcia21/subprocess" ) func main() { s := s

Jul 28, 2022
Comments
  • Respect json omitempty tag

    Respect json omitempty tag

    Currently adding omitempty in json tag has no impact.

    Expected behavior is that fields having valid = false should not be marshalled if omitempty is set.

  • Reduce dependency on time.Time

    Reduce dependency on time.Time

    Currently most of the date/time calculations are done by converting to time.Time and reverting afterwards to dt format.

    Ideally this step should be removed and the logic should be re-implemented from time.Time into dt.

A Go package for working with dates

date Package date provides functionality for working with dates. This package introduces a light-weight Date type that is storage-efficient and conven

Dec 13, 2022
Go package for calculating the sunrise and sunset times for a given location

go-sunrise Go package for calculating the sunrise and sunset times for a given location based on this method. Usage To calculate sunrise and sunset ti

Dec 13, 2022
Golang package to manipulate time intervals.

timespan timespan is a Go library for interacting with intervals of time, defined as a start time and a duration. Documentation API Installation Insta

Sep 26, 2022
timeutil - useful extensions (Timedelta, Strftime, ...) to the golang's time package

timeutil - useful extensions to the golang's time package timeutil provides useful extensions (Timedelta, Strftime, ...) to the golang's time package.

Dec 22, 2022
A Go package for working with dates

date Package date provides functionality for working with dates. This package introduces a light-weight Date type that is storage-efficient and coveni

May 24, 2022
Structural time package for jalali calendar

Jalali Structural time package for jalali calendar. This package support parse from string, json and time. Structures There are three data structures

Mar 21, 2022
Timediff is a Go package for printing human readable, relative time differences 🕰️

timediff is a Go package for printing human readable, relative time differences. Output is based on ranges defined in the Day.js JavaScript library, and can be customized if needed.

Dec 25, 2022
Gos: Armed Golang 💪 ( solutions for go module, goproxy, cross compilation, etc.)
Gos: Armed Golang 💪 ( solutions for go module, goproxy, cross compilation, etc.)

The current gos is still an alpha version, welcome more heroes to comment and improve it ?? , you can add more commands to it, or modify something to make it perform better.

Sep 15, 2022
A simple, semantic and developer-friendly golang package for datetime

Carbon 中文 | English carbon 是一个轻量级、语义化、对开发者友好的 Golang 时间处理库,支持链式调用和 gorm、xorm、zorm 等主流 orm。 如果您觉得不错,请给个 star 吧 github:github.com/golang-module/carbon g

Jan 9, 2023
The standard library flag package with its missing features

cmd Package cmd is a minimalistic library that enables easy sub commands with the standard flag library. This library extends the standard library fla

Oct 4, 2022