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
- Host: GitHub
- URL: https://github.com/lpar/calendar
- Owner: lpar
- License: bsd-3-clause
- Created: 2019-02-14T21:51:52.000Z (about 7 years ago)
- Default Branch: trunk
- Last Pushed: 2021-07-12T15:57:20.000Z (over 4 years ago)
- Last Synced: 2024-06-21T04:46:25.157Z (almost 2 years ago)
- Topics: date, golang, iso8601, json, sql, time
- Language: Go
- Size: 11.7 KB
- Stars: 6
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# calendar
[](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.