unixtimestamp

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

unixtimestamp package provides a time.Time wrapper that marshals to/from Unix timestamp (integer, seconds)

Index

Constants

This section is empty.

Variables

Endian is the default byte order for UnixTimestamp for MarshalBinary interface

View Source
var Errorf = fmt.Errorf
View Source
var FuncFrom = FSeconds // Change FuncTo also. consider FMilli.
View Source
var FuncTo = TSeconds // consider TMilli
View Source
var NoCheckTimeScan bool

Functions

func FMicro added in v0.0.5

func FMicro(t time.Time) int64

func FMilli added in v0.0.5

func FMilli(t time.Time) int64

func FSeconds added in v0.0.5

func FSeconds(t time.Time) int64

func TMicro added in v0.0.5

func TMicro(i int64) time.Time

func TMilli added in v0.0.5

func TMilli(i int64) time.Time

func TSeconds added in v0.0.5

func TSeconds(i int64) time.Time

Types

type UnixTimestamp

type UnixTimestamp = UnixTimestampNull

UnixTimestamp is a time.Time that marshals to/from Unix timestamp (seconds) Use pointer (*UnixTimestamp) and `omitempty` in structs for JSON marshaling Use Wrap(t) or Now() to create a UnixTimestamp

func New

func New(t time.Time) *UnixTimestamp

New existing time.Time

func Now

func Now() *UnixTimestamp

Now returns a new UnixTimestamp for the current time

func (UnixTimestamp) MarshalBinary

func (ut UnixTimestamp) MarshalBinary() ([]byte, error)

MarshalBinary uses Endian var, set Endian to binary.BigEndian if needed

func (UnixTimestamp) MarshalJSON

func (ut UnixTimestamp) MarshalJSON() ([]byte, error)

func (*UnixTimestamp) Scan added in v0.0.5

func (u *UnixTimestamp) Scan(v interface{}) error

func (*UnixTimestamp) String added in v0.0.7

func (ut *UnixTimestamp) String() string

func (*UnixTimestamp) UnmarshalBinary

func (ut *UnixTimestamp) UnmarshalBinary(dat []byte) error

UnmarshalBinary uses Endian var, set Endian to binary.BigEndian if needed

func (*UnixTimestamp) UnmarshalJSON

func (ut *UnixTimestamp) UnmarshalJSON(dat []byte) error

func (*UnixTimestamp) Value added in v0.0.5

func (u *UnixTimestamp) Value() (driver.Value, error)

Value is returns nil if zero time. Wrap with UnixTimestampNotNull for not null

type UnixTimestampNotNull added in v0.0.6

type UnixTimestampNotNull struct {
	UnixTimestamp
}

type UnixTimestampNull added in v0.0.6

type UnixTimestampNull struct {
	time.Time
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL