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 Now(_ context.Context, args ...core.Value) (core.Value, error)
- func RegisterLib(ns core.Namespace) error
- type Unit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Date ¶
DATE parses a formatted string and returns DateTime object it represents. @param {String} time - String representation of DateTime. @param {String} [layout = "2006-01-02T15:04:05Z07:00"] - String layout. @return {DateTime} - New DateTime object derived from timeString.
func DateAdd ¶
DATE_ADD adds amount given in unit to 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 @param {DateTime} date - Source date. @param {Int} amount - Amount of units @param {String} unit - Unit. @return {DateTime} - Calculated date.
func DateCompare ¶
DATE_COMPARE checks if two partial dates match. @param {DateTime} date1 - First date. @param {DateTime} date2 - Second date. @param {String} unitRangeStart - Unit to start from. @param {String} [unitRangeEnd="millisecond"] - 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 ¶
DATE_DAY returns the day of date as a number. @param {DateTime} date - Source DateTime. @return {Int} - A day number.
func DateDayOfWeek ¶
DATE_DAYOFWEEK returns number of the weekday from the date. Sunday is the 0th day of week. @param {DateTime} date - Source DateTime. @return {Int} - Number of the weekday.
func DateDayOfYear ¶
DATE_DAYOFYEAR returns the day of year number of date. The return value range from 1 to 365 (366 in a leap year). @param {DateTime} date - Source DateTime. @return {Int} - A day of year number.
func DateDaysInMonth ¶
DATE_DAYS_IN_MONTH returns the number of days in the month of date. @param {DateTime} date - Source DateTime. @return {Int} - Number of the days.
func DateDiff ¶
DATE_DIFF returns the difference between two dates in given time unit. @param {DateTime} date1 - First date. @param {DateTime} date2 - Second date. @param {String} unit - Time unit to return the difference in. @param {Boolean} [asFloat=False] - If true amount of unit will be as float. @return {Int | Float} - Difference between date1 and date2.
func DateFormat ¶
DATE_FORMAT format date according to the given format string. @param {DateTime} date - Source DateTime object. @param {String} format - String format. @return {String} - Formatted date.
func DateHour ¶
DATE_HOUR returns the hour of date as a number. @param {DateTime} date - Source DateTime. @return {Int} - An hour number.
func DateLeapYear ¶
DATE_LEAPYEAR returns true if date is in a leap year else false. @param {DateTime} date - Source DateTime. @return {Boolean} - Date is in a leap year.
func DateMillisecond ¶
DATE_MILLISECOND returns the millisecond of date as a number. @param {DateTime} date - Source DateTime. @return {Int} - A millisecond number.
func DateMinute ¶
DATE_MINUTE returns the minute of date as a number. @param {DateTime} date -Source DateTime. @return {Int} - A minute number.
func DateMonth ¶
DATE_MONTH returns the month of date as a number. @param {DateTime} date - Source DateTime. @return {Int} - A month number.
func DateQuarter ¶
DATE_QUARTER returns which quarter date belongs to. @param {DateTime} date - Source DateTime. @return {Int} - A quarter number.
func DateSecond ¶
DATE_SECOND returns the second of date as a number. @param {DateTime} date - Source DateTime. @return {Int} - A second number.
func DateSubtract ¶
DATE_SUBTRACT subtract amount given in unit to 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 @param {DateTime} date - source date. @param {Int} amount - amount of units @param {String} unit - unit. @return {DateTime} - calculated date.
func DateYear ¶
DATE_YEAR returns the year extracted from the given date. @param {DateTime} date - 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.
func Now ¶
NOW returns new DateTime object with Time equal to time.Now(). @return {DateTime} - New DateTime object.
func RegisterLib ¶ added in v0.10.1
Types ¶
type Unit ¶
type Unit int
Unit specifies an unit of time (Millisecond, 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