Documentation ¶
Index ¶
- Constants
- func AddDaysToStrDate(date string, days int) (string, error)
- func DateFromEpoch(t int64) time.Time
- func DateRange(ref time.Time, timeunit int64) (int64, int64)
- func DateRangePrevious(ref int64, timeunit int64) (int64, int64)
- func EndofDay(tv int64) int64
- func EpochMinuteApart(epoch1, epoch2 int64) bool
- func EpochNow() int64
- func GetSignalDate(timeUnit int32, refDate time.Time) string
- func GetSignalTime(timeUnit int32, refDate time.Time) time.Time
- func GetTimeUnitString(timeUnit int32) string
- func ISODate() string
- func ISODateFromTime(t time.Time) string
- func ISODateOffsetToTime(date string) (time.Time, error)
- func ISODateToEpoch(date string) (int64, error)
- func ISODateToTime(date string) (time.Time, error)
- func ShortDate(date string) string
- func ShortDateFromEpoch(t int64) string
- func ShortDateFromTime(tv time.Time) string
- func StartofDay(tv int64) int64
- func TimeToEpoch(tv time.Time) int64
- func ToMilliSec(date time.Time) int64
- func ToTimeRange(tv time.Time, days int) (int64, int64)
- type Date
Constants ¶
const ( // SignalTimeUnitNOW is now SignalTimeUnitNOW int32 = 0 // SignalTimeUnitMONTH is 30 days SignalTimeUnitMONTH int32 = 30 // SignalTimeUnitQUARTER is 90 days SignalTimeUnitQUARTER int32 = 90 // SignalTimeUnitHALFYEAR is 180 days SignalTimeUnitHALFYEAR int32 = 180 // SignalTimeUnitYEAR is 365 days SignalTimeUnitYEAR int32 = 365 // SignalTimeUnitTHIRDQUARTER is 270 days SignalTimeUnitTHIRDQUARTER int32 = 270 // SignalTimeUnitALLTIME is all time SignalTimeUnitALLTIME int32 = -1 // SignalTimeUnitBIMONTH is two month SignalTimeUnitBIMONTH int32 = 60 // DaysInMilliseconds is one day in milliseconds DaysInMilliseconds int64 = 86400000 )
const RFC3339 = "2006-01-02T15:04:05.999999999-07:00"
RFC3339 There is an edge case where there is no timezone set and that makes the format function return dates like 2019-09-03T20:48:57.073Z. We are using this RFC3339 custom format to always get an offset.
Variables ¶
This section is empty.
Functions ¶
func AddDaysToStrDate ¶
AddDaysToStrDate will add days to string date
func DateFromEpoch ¶
DateFromEpoch returns a time.Time from an epoch value in milliseconds
func DateRange ¶
DateRange will return the beginning and end of a date range for a given time unit. if the timeunit is -1 it will return epoch zero
func DateRangePrevious ¶
DateRangePrevious will previous time date for the previous range from timeunit
func EpochMinuteApart ¶
EpochMinuteApart returns true if both epochs are less than or equal to one minute apart
func EpochNow ¶
func EpochNow() int64
EpochNow will return the current time in epoch (in UTC) with millisecond precision
func GetSignalDate ¶
GetSignalDate returns a metric date in short form for a time unit from the ref date
func GetSignalTime ¶
GetSignalTime returns a metric date for a time unit from the ref date This will be changed from -30 to -29 because of the next example Lets say I want to take 1 day from "yesterday at the end" lets say "2017-02-26 23:59:59.9999" that will result in "2017-02-25 23:59:59.9999" and after truncate "2017-02-25 00:00:00" so it is actually taken 2 days
func GetTimeUnitString ¶
GetTimeUnitString will return the timeunit as a string
func ISODate ¶
func ISODate() string
ISODate returns a RFC 3339 formatted string for the current date time
func ISODateFromTime ¶
ISODateFromTime returns a RFC 3339 formatted string from the supplied timestamp
func ISODateOffsetToTime ¶
ISODateOffsetToTime returns a RFC 3339 formatted string as a timestamp
func ISODateToEpoch ¶
ISODateToEpoch returns an epoch date or 0 if invalid or empty
func ISODateToTime ¶
ISODateToTime returns a RFC 3339 formatted string as a timestamp
func ShortDateFromEpoch ¶
ShortDateFromEpoch will return a short date from a epoch value in milliseconds
func ShortDateFromTime ¶
ShortDateFromTime will return a short date from a time
func StartofDay ¶
StartofDay returns the start of the day (just after midnight) for a given epoch time
func TimeToEpoch ¶
TimeToEpoch will convert a time to epoch (in UTC) with millisecond precision
func ToMilliSec ¶
ToMilliSec Convert time to milliseconds int64
Types ¶
type Date ¶
type Date struct { // Epoch the date in epoch format Epoch int64 `json:"epoch" bson:"epoch" yaml:"epoch" faker:"-"` // Offset the timezone offset from GMT Offset int64 `json:"offset" bson:"offset" yaml:"offset" faker:"-"` // Rfc3339 the date in RFC3339 format Rfc3339 string `json:"rfc3339" bson:"rfc3339" yaml:"rfc3339" faker:"-"` }
Date represents the object structure for date
func NewDateFromEpoch ¶
NewDateFromEpoch returns a new Date object from a epoch time value