Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/myusuf3/times
simplified and consistent times and timezone library in golang.
https://github.com/myusuf3/times
Last synced: 29 days ago
JSON representation
simplified and consistent times and timezone library in golang.
- Host: GitHub
- URL: https://github.com/myusuf3/times
- Owner: myusuf3
- License: mit
- Created: 2015-04-27T00:11:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-04-27T03:55:52.000Z (over 9 years ago)
- Last Synced: 2024-06-20T17:48:26.577Z (5 months ago)
- Language: Go
- Size: 172 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# times
simplified and consistent times and timezones library in golang.Golang has an awesome `time` package compared to most languages but the
return values aren't always the most sane or consistent.This library is fairly opinionated on how you should deal with times
internally in your system and how you should deal with timezones.The general idea being that internally to your app simple user UTC as
your timezone/local and only change out to localized/normalized version
of your time for representation view in your application. e.g. when the
user in a specific locale is interacting with your application.This library aims to provide a consisent api for such interactions as a
wrapper around the `time` package in golang proper.For example the Parse function in the `time` package is full of caveats
which can be less than convient trying to remember in the heat of the moment!>In the absence of a time zone indicator, Parse returns a time in UTC.
>When parsing a time with a zone offset like -0700, if the offset corresponds to a time zone used by the current location (Local), then Parse uses that location and zone in the returned time. Otherwise it records the time as being in a fabricated location with time fixed at the given zone offset.
Check out the double name reuse of Unix in the package as well. Granted one operates on
a `Time` instance but still, you had all the colors of the wind.# func (Time) Unix
> Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.
#func Unix
> Unix returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC. It is valid to pass nsec outside the range [0, 999999999].