An open API service indexing awesome lists of open source software.

https://github.com/lpar/calendar

Go calendar Date (only), clock Time (only), and nullable versions of same, with sensible JSON and SQL behavior
https://github.com/lpar/calendar

date golang iso8601 json sql time

Last synced: 3 months ago
JSON representation

Go calendar Date (only), clock Time (only), and nullable versions of same, with sensible JSON and SQL behavior

Awesome Lists containing this project

README

          

# calendar

[![GoDoc](https://godoc.org/github.com/lpar/calendar?status.svg)](https://godoc.org/github.com/lpar/calendar)

Go calendar Date (only), clock Time (only), and nullable versions of same, with sensible JSON and SQL behavior.

I wrote this because I needed:

* calendar dates (with no associated time)
* clock times (with no associated date)
* with no time zone (time zone to be stored separately as an Olsen TZDB value)
* with support for nullable dates/times
* compatible with PostgreSQL DATE and TIME types, and
* with sensible ISO-8601 bare-date and bare-time JSON representations

So I can define a structure with (say):

```
StartDate calendar.Date `json:"start_date"`
StartTime calendar.NullTime `json:"start_time"`
EndDate calendar.Date `json:"end_date"`
EndTime calendar.NullTime `json:"end_time"`
TimeZone string `json:"timezone"`
```

and scan in values from a PostgreSQL database, and serialize them to JSON, and get out something like:

…`"start_date":"2019-02-14","start_time":"09:00:00","end_date":"2019-02-14","end_time":"17:00:00","timezone":"Americas/Chicago"`…

If you don't have those precise requirements, this is not the date/time library for you.