Documentation ¶
Index ¶
- Constants
- func IsDurationEnabledAndValid(durationWithEnabled *DurationWithEnabled) bool
- type CpsTime
- func (t CpsTime) After(u CpsTime) bool
- func (t CpsTime) Before(u CpsTime) bool
- func (t CpsTime) EqualDay(u CpsTime) bool
- func (t CpsTime) Format() string
- func (t CpsTime) In(loc *time.Location) CpsTime
- func (t CpsTime) MarshalBSONValue() (bsontype.Type, []byte, error)
- func (t CpsTime) MarshalJSON() ([]byte, error)
- func (t *CpsTime) UnmarshalBSONValue(valueType bsontype.Type, b []byte) error
- func (t *CpsTime) UnmarshalJSON(b []byte) error
- type DurationWithEnabled
- type DurationWithUnit
- type MicroTime
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 ¶
CpsTime allows conversion from time.Time to time.Time.Unix()
func NewCpsTime ¶
NewCpsTime create a CpsTime from a timestamp
func (CpsTime) MarshalBSONValue ¶
MarshalBSONValue converts from CpsTime to timestamp as bytes
func (CpsTime) MarshalJSON ¶
MarshalJSON converts from CpsTime to timestamp as bytes
func (*CpsTime) UnmarshalBSONValue ¶
UnmarshalBSONValue converts from timestamp as bytes to CpsTime
func (*CpsTime) UnmarshalJSON ¶
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 ¶
func (d DurationWithUnit) To(unit string) (DurationWithUnit, error)
type MicroTime ¶
func NewMicroTime ¶
func NewMicroTime() MicroTime
func (MicroTime) MarshalBSONValue ¶
func (MicroTime) MarshalJSON ¶
func (*MicroTime) UnmarshalBSONValue ¶
func (*MicroTime) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.