datetime

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DurationUnitSecond = "s"
	DurationUnitMinute = "m"
	DurationUnitHour   = "h"
	DurationUnitDay    = "d"
	DurationUnitWeek   = "w"
	DurationUnitMonth  = "M"
	DurationUnitYear   = "y"
)

Variables

This section is empty.

Functions

func IsDurationEnabledAndValid

func IsDurationEnabledAndValid(durationWithEnabled *DurationWithEnabled) bool

Types

type CpsTime

type CpsTime struct {
	time.Time
}

CpsTime allows conversion from time.Time to time.Time.Unix()

func NewCpsTime

func NewCpsTime(timestamp ...int64) CpsTime

NewCpsTime create a CpsTime from a timestamp

func (CpsTime) After

func (t CpsTime) After(u CpsTime) bool

func (CpsTime) Before

func (t CpsTime) Before(u CpsTime) bool

func (CpsTime) EqualDay

func (t CpsTime) EqualDay(u CpsTime) bool

func (CpsTime) Format

func (t CpsTime) Format() string

Format easilly format a CpsTime as a string

func (CpsTime) In

func (t CpsTime) In(loc *time.Location) CpsTime

func (CpsTime) MarshalBSONValue

func (t CpsTime) MarshalBSONValue() (bsontype.Type, []byte, error)

MarshalBSONValue converts from CpsTime to timestamp as bytes

func (CpsTime) MarshalJSON

func (t CpsTime) MarshalJSON() ([]byte, error)

MarshalJSON converts from CpsTime to timestamp as bytes

func (*CpsTime) UnmarshalBSONValue

func (t *CpsTime) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

UnmarshalBSONValue converts from timestamp as bytes to CpsTime

func (*CpsTime) UnmarshalJSON

func (t *CpsTime) UnmarshalJSON(b []byte) error

UnmarshalJSON converts from string to CpsTime

type DurationWithEnabled

type DurationWithEnabled struct {
	DurationWithUnit `bson:",inline"`
	Enabled          *bool `bson:"enabled" json:"enabled" binding:"required"`
}

type DurationWithUnit

type DurationWithUnit struct {
	Value int64  `bson:"value" json:"value" binding:"required,min=1"`
	Unit  string `bson:"unit" json:"unit" binding:"required,oneof=s m h d w M y"`
}

DurationWithUnit represent duration with user-preferred units

func NewDurationWithUnit

func NewDurationWithUnit(value int64, unit string) DurationWithUnit

func ParseDurationWithUnit

func ParseDurationWithUnit(str string) (DurationWithUnit, error)

func (DurationWithUnit) AddTo

func (d DurationWithUnit) AddTo(t CpsTime) CpsTime

func (DurationWithUnit) IsZero

func (d DurationWithUnit) IsZero() bool

func (DurationWithUnit) String

func (d DurationWithUnit) String() string

func (DurationWithUnit) SubFrom

func (d DurationWithUnit) SubFrom(t CpsTime) CpsTime

func (DurationWithUnit) To

type MicroTime

type MicroTime struct {
	time.Time
}

func NewMicroTime

func NewMicroTime() MicroTime

func (MicroTime) MarshalBSONValue

func (t MicroTime) MarshalBSONValue() (bsontype.Type, []byte, error)

func (MicroTime) MarshalJSON

func (t MicroTime) MarshalJSON() ([]byte, error)

func (*MicroTime) UnmarshalBSONValue

func (t *MicroTime) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error

func (*MicroTime) UnmarshalJSON

func (t *MicroTime) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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