Files
x-realy/timestamp/timestamp.go
mleku e12fb03b03 partly completed filter search
since/until/kinds/authors combinations done
2025-06-12 11:32:44 +01:00

20 lines
375 B
Go

package timestamp
import (
"time"
"golang.org/x/exp/constraints"
)
type Timestamp int64
func Now() Timestamp { return Timestamp(time.Now().Unix()) }
func New[T constraints.Integer | constraints.Float](t T) Timestamp {
return Timestamp(t)
}
func (t Timestamp) Time() time.Time { return time.Unix(int64(t), 0) }
func (t Timestamp) ToInt64() int64 { return int64(t) }