Documentation ¶
Index ¶
- func AddUnit(tm time.Time, amount int, u Unit) (res time.Time)
- func Date(_ context.Context, args ...core.Value) (core.Value, error)
- func DateAdd(_ context.Context, args ...core.Value) (core.Value, error)
- func DateCompare(_ context.Context, args ...core.Value) (core.Value, error)
- func DateDay(_ context.Context, args ...core.Value) (core.Value, error)
- func DateDayOfWeek(_ context.Context, args ...core.Value) (core.Value, error)
- func DateDayOfYear(_ context.Context, args ...core.Value) (core.Value, error)
- func DateDaysInMonth(_ context.Context, args ...core.Value) (core.Value, error)
- func DateDiff(_ context.Context, args ...core.Value) (core.Value, error)
- func DateFormat(_ context.Context, args ...core.Value) (core.Value, error)
- func DateHour(_ context.Context, args ...core.Value) (core.Value, error)
- func DateLeapYear(_ context.Context, args ...core.Value) (core.Value, error)
- func DateMillisecond(_ context.Context, args ...core.Value) (core.Value, error)
- func DateMinute(_ context.Context, args ...core.Value) (core.Value, error)
- func DateMonth(_ context.Context, args ...core.Value) (core.Value, error)
- func DateQuarter(_ context.Context, args ...core.Value) (core.Value, error)
- func DateSecond(_ context.Context, args ...core.Value) (core.Value, error)
- func DateSubtract(_ context.Context, args ...core.Value) (core.Value, error)
- func DateYear(_ context.Context, args ...core.Value) (core.Value, error)
- func IsDatesEqual(tm1, tm2 time.Time, u Unit) bool
- func NewLib() map[string]core.Function
- func Now(_ context.Context, args ...core.Value) (core.Value, error)
- type Unit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Date ¶
Date convert RFC3339 date time string to DateTime object. @params timeString (String) - string in RFC3339 format. @return (DateTime) - new DateTime object derived from timeString.
func DateAdd ¶
DateAdd add amount given in unit to date. @params date (DateTime) - source date. @params amount (Int) - amount of units @params unit (String) - unit. @return (DateTime) - calculated date. The following units are available: * y, year, year * m, month, months * w, week, weeks * d, day, days * h, hour, hours * i, minute, minutes * s, second, seconds * f, millisecond, milliseconds
func DateCompare ¶
DateCompare check if two partial dates match. @params date1, date2 (DateTime) - comparable dates. @params unitRangeStart (String) - unit to start from. @params unitRangeEnd (String, Optional) - unit to end with. Error will be returned if unitRangeStart unit less that unitRangeEnd. @return (Boolean) - true if the dates match, else false.
func DateDay ¶
DateDay returns the day of date as a number. @params date (DateTime) - source DateTime. @return (Int) - a day number.
func DateDayOfWeek ¶
DateDayOfWeek returns number of the weekday from the date. Sunday is the 0th day of week. @params date (DateTime) - source DateTime. @return (Int) - return number of the weekday.
func DateDayOfYear ¶
DateDayOfYear returns the day of year number of date. The return value range from 1 to 365 (366 in a leap year). @params date (DateTime) - source DateTime. @return (Int) - a day of year number.
func DateDaysInMonth ¶
DateDaysInMonth returns the number of days in the month of date. @params date (DateTime) - source DateTime. @return (Int) - number of the days.
func DateDiff ¶
DateDiff returns the difference between two dates in given time unit. @params date1 (DateTime) - first DateTime. @params date2 (DateTime) - second DateTime. @params unit (String) - time unit to return the difference in. @params asFloat (Boolean, optional) - if true amount of unit will be as float. @return (Int, Float) - difference between date1 and date2.
func DateFormat ¶
DateFormat format date according to the given format string. @params date (DateTime) - source DateTime object. @return (String) - formatted date.
func DateHour ¶
DateHour returns the hour of date as a number. @params date (DateTime) - source DateTime. @return (Int) - a hour number.
func DateLeapYear ¶
DateLeapYear returns true if date is in a leap year else false. @params date (DateTime) - source DateTime. @return (Boolean) - date is in a leap year.
func DateMillisecond ¶
DateMillisecond returns the millisecond of date as a number. @params date (DateTime) - source DateTime. @return (Int) - a millisecond number.
func DateMinute ¶
DateMinute returns the minute of date as a number. @params date (DateTime) - source DateTime. @return (Int) - a minute number.
func DateMonth ¶
DateMonth returns the month of date as a number. @params date (DateTime) - source DateTime. @return (Int) - a month number.
func DateQuarter ¶
DateQuarter returns which quarter date belongs to. @params date (DateTime) - source DateTime. @return (Int) - a quarter number.
func DateSecond ¶
DateSecond returns the second of date as a number. @params date (DateTime) - source DateTime. @return (Int) - a second number.
func DateSubtract ¶
DateSubtract subtract amount given in unit to date. @params date (DateTime) - source date. @params amount (Int) - amount of units @params unit (String) - unit. @return (DateTime) - calculated date. The following units are available: * y, year, year * m, month, months * w, week, weeks * d, day, days * h, hour, hours * i, minute, minutes * s, second, seconds * f, millisecond, milliseconds
func DateYear ¶
DateYear returns the year extracted from the given date. @params date (DateTime) - source DateTime. @return (Int) - a year number.
func IsDatesEqual ¶
IsDatesEqual check if two partial dates match. This case the day means not the amount of days in Time, but the day of the month. The same rules applied to each unit.
Types ¶
type Unit ¶
type Unit int
Unit specifies an unit of time (Millsecond, Second...).
func UnitFromString ¶
UnitFromString returns true and an Unit object if Unit with that name exists. Returns false, otherwise.
func (Unit) Nanosecond ¶
Nanosecond returns representation of an Unit in nanosconds