datetime

package
v2.0.0-alpha.64 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, arg1, arg2, arg3 runtime.Value) (runtime.Value, error)

Add adds an integer number of units to a date. Subday units are elapsed time; calendar units use Go AddDate in the input's location, normalizing month ends rather than clamping them. A calendar day can span 23 or 25 elapsed hours. @param date {DateTime} Source date. @param amount {Int} Number of units to add; may be negative. @param unit {String} Millisecond, second, minute, hour, day, week, month, or year; plurals are accepted. @return {DateTime} Calculated date, retaining the input's location. @throws {RangeError} The shift or resulting date cannot be represented safely.

func Day

Day returns the day of date as a number. @param date {DateTime} Source DateTime. @return {Int} A day number.

func DayOfWeek

func DayOfWeek(_ context.Context, arg runtime.Value) (runtime.Value, error)

DayOfWeek returns number of the weekday from the date. Sunday is the 0th day of week. @param date {DateTime} Source DateTime. @return {Int} Number of the weekday.

func DayOfYear

func DayOfYear(_ context.Context, arg runtime.Value) (runtime.Value, error)

DayOfYear returns the day of year number of date. The return value range from 1 to 365 (366 in a leap year). @param date {DateTime} Source DateTime. @return {Int} A day of year number.

func DaysInMonth

func DaysInMonth(_ context.Context, arg runtime.Value) (runtime.Value, error)

DaysInMonth returns the number of days in the input's local calendar month. @param date {DateTime} Source date. @return {Int} Number of calendar days in the month, including leap days.

func Diff

func Diff(ctx context.Context, arg1, arg2, arg3 runtime.Value) (runtime.Value, error)

Diff returns the signed elapsed difference right - left in fixed units. It uses checked runtime subtraction, limited to Duration's roughly 292-year range. @param left {DateTime} Starting instant. @param right {DateTime} Ending instant. @param unit {String} Millisecond, second, minute, or hour; plurals are accepted. Calendar units are rejected. @return {Float} Signed fractional elapsed units; reversing arguments reverses the sign. @throws {TypeError} An argument has an invalid type. @throws {InvalidArgument} The unit is unknown or is a calendar unit. @throws {RangeError} The elapsed interval cannot fit a runtime Duration.

func Format

func Format(_ context.Context, arg1, arg2 runtime.Value) (runtime.Value, error)

Format renders a DateTime using a Go time layout. @param date {DateTime} Source DateTime object. @param format {String} Go time layout. @return {String} Formatted date.

func Hour

func Hour(_ context.Context, arg runtime.Value) (runtime.Value, error)

Hour returns the hour of date as a number. @param date {DateTime} Source DateTime. @return {Int} An hour number.

func IsLeapYear

func IsLeapYear(_ context.Context, arg runtime.Value) (runtime.Value, error)

IsLeapYear returns true if date is in a leap year else false. @param date {DateTime} Source DateTime. @return {Boolean} Whether the date is in a leap year.

func Millisecond

func Millisecond(_ context.Context, arg runtime.Value) (runtime.Value, error)

Millisecond returns the millisecond of date as a number. @param date {DateTime} Source DateTime. @return {Int} A millisecond number.

func Minute

func Minute(_ context.Context, arg runtime.Value) (runtime.Value, error)

Minute returns the minute of date as a number. @param date {DateTime} Source DateTime. @return {Int} A minute number.

func Month

func Month(_ context.Context, arg runtime.Value) (runtime.Value, error)

Month returns the month of date as a number. @param date {DateTime} Source DateTime. @return {Int} A month number.

func Now

func Now(_ context.Context) (runtime.Value, error)

Now returns new DateTime object with Time equal to time.Now(). @return {DateTime} New DateTime object.

func Parse

func Parse(ctx context.Context, args ...runtime.Value) (runtime.Value, error)

Parse parses a String using an optional Go time layout, defaulting to RFC3339. @param time {String} String representation of DateTime. @param layout {String} Go time layout. @return {DateTime} Parsed DateTime, preserving the parsed offset.

func Quarter

func Quarter(_ context.Context, arg runtime.Value) (runtime.Value, error)

Quarter returns which quarter date belongs to. @param date {DateTime} Source DateTime. @return {Int} A quarter number.

func RegisterLib

func RegisterLib(ns runtime.Namespace)

RegisterLib registers canonical datetime functions and deprecated global adapters. @namespace datetime

func Same

func Same(_ context.Context, arg1, arg2, arg3 runtime.Value) (runtime.Value, error)

Same compares each input's own local calendar through the requested precision. Offset and location identity are ignored. Week compares ISO week-year and week number; other units require all enclosing calendar fields to match. @param left {DateTime} First date. @param right {DateTime} Second date. @param unit {String} Precision: year, month, week, day, hour, minute, second, or millisecond; plurals are accepted. @return {Boolean} Whether the local calendar values match through that precision. @throws {TypeError} An argument has an invalid type. @throws {InvalidArgument} The unit is unknown.

func Second

func Second(_ context.Context, arg runtime.Value) (runtime.Value, error)

Second returns the second of date as a number. @param date {DateTime} Source DateTime. @return {Int} A second number.

func Subtract

func Subtract(ctx context.Context, arg1, arg2, arg3 runtime.Value) (runtime.Value, error)

Subtract subtracts an integer number of units from a date. Subday units are elapsed time; calendar units use Go AddDate in the input's location, normalizing month ends rather than clamping them. A calendar day can span 23 or 25 hours. @param date {DateTime} Source date. @param amount {Int} Number of units to subtract; may be negative. @param unit {String} Millisecond, second, minute, hour, day, week, month, or year; plurals are accepted. @return {DateTime} Calculated date, retaining the input's location. @throws {RangeError} The shift or resulting date cannot be represented safely.

func Year

func Year(_ context.Context, arg runtime.Value) (runtime.Value, error)

Year returns the year extracted from the given date. @param date {DateTime} Source DateTime. @return {Int} A year number.

Types

This section is empty.

Jump to

Keyboard shortcuts

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