mirror of
https://github.com/jimeh/go-tyme.git
synced 2026-02-19 09:56:42 +00:00
feat(tyme/ts): add ts package
This commit is contained in:
23
ts/unix.go
Normal file
23
ts/unix.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package ts
|
||||
|
||||
import "time"
|
||||
|
||||
// UnixSecond parses a given int64 as a Unix timestamp with second accuracy.
|
||||
func UnixSecond(ts int64) Second {
|
||||
return Second(time.Unix(ts, 0))
|
||||
}
|
||||
|
||||
// UnixMilli parses a given int64 as a Unix timestamp with millisecond accuracy.
|
||||
func UnixMilli(ts int64) Millisecond {
|
||||
return Millisecond(time.UnixMilli(ts))
|
||||
}
|
||||
|
||||
// UnixMicro parses a given int64 as a Unix timestamp with microsecond accuracy.
|
||||
func UnixMicro(ts int64) Microsecond {
|
||||
return Microsecond(time.UnixMicro(ts))
|
||||
}
|
||||
|
||||
// UnixNano parses a given int64 as a Unix timestamp with nanosecond accuracy.
|
||||
func UnixNano(ts int64) Nanosecond {
|
||||
return Nanosecond(unixNano(ts))
|
||||
}
|
||||
Reference in New Issue
Block a user