https://github.com/invzhi/timex
:date: A Go package that extends the standard library time with dedicated date and time-of-day types.
https://github.com/invzhi/timex
date go golang
Last synced: 6 months ago
JSON representation
:date: A Go package that extends the standard library time with dedicated date and time-of-day types.
- Host: GitHub
- URL: https://github.com/invzhi/timex
- Owner: invzhi
- License: mit
- Created: 2023-03-26T10:05:52.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-11-14T07:40:54.000Z (8 months ago)
- Last Synced: 2025-11-14T08:34:06.067Z (8 months ago)
- Topics: date, go, golang
- Language: Go
- Homepage:
- Size: 50.8 KB
- Stars: 20
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# timex
[](https://pkg.go.dev/github.com/invzhi/timex)
[](https://goreportcard.com/report/github.com/invzhi/timex)
[](https://codecov.io/gh/invzhi/timex)
📅 A Go package that extends the standard library time with dedicated date and time-of-day types.
## Why use timex?
`timex` is a lightweight and efficiently designed Go package that provides dedicated `Date` and `TimeOfDay` types. It's built with 100% unit test coverage and has no third-party dependencies, making it a reliable choice for time-related operations.
- **Missing Standard Library Types:** Go's `time` package lacks distinct types for handling just a date or just a time of day. `timex` introduces `Date` and `TimeOfDay` to bridge this gap, offering a more intuitive and focused API for these specific use cases.
- **Simplicity and Clarity:** Our `Date` type focuses exclusively on date operations (YYYY-MM-DD), avoiding timezone-related issues inherent in `time.Time` when only a calendar date matters. Similarly, `TimeOfDay` provides a clear HH:mm:ss format for operations strictly on time, independent of any particular date.
- **Lightweight & Efficient:** `timex` is designed to be lean, with fast method implementations that often outperform `time.Time` for specific date and time-of-day calculations. It's built without any external dependencies, ensuring a minimal footprint.
- **Database & JSON Compatibility:** Work directly with `DATE` and `TIME` types in databases like MySQL or PostgreSQL, and effortlessly serialize/deserialize these types to and from JSON.
- **Reliability:** With 100% unit test coverage, you can be confident in the package's correctness and stability.
## Getting Started
```
go get github.com/invzhi/timex
```
## Reference
- [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
- [Date Type Proposal](https://github.com/golang/go/issues/21365)