https://github.com/raspi/uint64timestamp
timestamp fitted into uint64
https://github.com/raspi/uint64timestamp
binary date datetime golang golang-library library time timestamp uint64
Last synced: 7 months ago
JSON representation
timestamp fitted into uint64
- Host: GitHub
- URL: https://github.com/raspi/uint64timestamp
- Owner: raspi
- License: apache-2.0
- Created: 2023-05-15T11:01:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-17T07:30:13.000Z (over 2 years ago)
- Last Synced: 2025-02-25T22:46:32.463Z (11 months ago)
- Topics: binary, date, datetime, golang, golang-library, library, time, timestamp, uint64
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# uint64timestamp



[](https://goreportcard.com/report/github.com/raspi/uint64timestamp)
Timestamp fitted into uint64.
There are two different versions: Base10 which is for humans and more binary packed Base2.
| | Base10 | Base2 |
|----------|--------------------------|------------------------------|
| Accuracy | microseconds (tens (10)) | nanoseconds (hundreds (100)) |
## Base10 - human parsable
See [pkg/base10](pkg/base10) for details.
Example:
`2023051514142573247` is 2023-05-15 14:14:25.73247
```go
now := time.Now()
bin, err := base10.TimeToUint64(now)
if err != nil {
panic(err)
}
humanTime, err := base10.Uint64ToTime(bin, now.Location())
if err != nil {
panic(err)
}
```
## Base2 - binary
See [pkg/base2](pkg/base2) for details.
Example:
`2278081318148840948` is 2023-05-15 14:14:25.732479
```go
now := time.Now()
bin, err := base2.TimeToUint64(now)
if err != nil {
panic(err)
}
binTime, err := base2.Uint64ToTime(bin, now.Location())
if err != nil {
panic(err)
}
```