datetime

Functions for date and time manipulation.

Summary
datetimeFunctions for date and time manipulation.
Types
InstantRepresents a particular instant in global time.
DateTimeRepresents a particular instant in global time, broken down to components in UTC.
IntervalRepresents a time period between a start and an end time.
DurationRepresents a specific amount of time measured in seconds.
PeriodRepresents an amount of time measured by components.
Functions
nowReturn the current timestamp as a DateTime.
makeFromInstantConvert a specific instant into a DateTime record.
makeFromPartsGiven timestamp parts, return a DateTime representing the instant.
makeFromStringMake a DateTime from a string representation.
DateTime.minusDurationSubtract a Duration from a DateTime and return a new DateTime.
DateTime.minusPeriodSubtract a Period from a DateTime and return a new DateTime.
DateTime.plusDurationAdd a Duration to a DateTime and return a new DateTime.
DateTime.plusPeriodAdd a Period to a DateTime and return a new DateTime.
DateTime.toStringReturn an ISO 8601 formatted representation of a DateTime.
DateTime.withDateReturn a new DateTime with the given year, month, and day based on an existing DateTime.
DateTime.withYearReturn a new DateTime with the given year based on an existing DateTime.
DateTime.withMonthReturn a new DateTime with the given month based on an existing DateTime.
DateTime.withDayReturn a new DateTime with the given day based on an existing DateTime.
DateTime.withTimeReturn a new DateTime with the given hour, minute, and second based on an existing DateTime.
DateTime.withHourReturn a new DateTime with the given hour based on an existing DateTime.
DateTime.withMinuteReturn a new DateTime with the given minute based on an existing DateTime.
DateTime.withSecondReturn a new DateTime with the given second based on an existing DateTime.

Types

Instant

Represents a particular instant in global time.

DateTime

Represents a particular instant in global time, broken down to components in UTC.

Fields

yearyear
monthmonth (1=January, 12=December)
dayday
weekdayweekday (1=Monday, 7=Sunday)
hourhour
minuteminute
secondsecond

Interval

Represents a time period between a start and an end time.

Fields

startstart
endend

Duration

Represents a specific amount of time measured in seconds.

Period

Represents an amount of time measured by components.

Fields

yearsyears
monthsmonths
daysdays
hourshours
minutesminutes
secondsseconds

Functions

now

FUNCTION now(): DateTime

Return the current timestamp as a DateTime.

makeFromInstant

FUNCTION makeFromInstant(inst: Instant): DateTime

Convert a specific instant into a DateTime record.

makeFromParts

FUNCTION makeFromParts(dt: DateTime): DateTime

Given timestamp parts, return a DateTime representing the instant.  This function must be called after filling in an empty DateTime.

makeFromString

FUNCTION makeFromString(s: String): DateTime

Make a DateTime from a string representation.

DateTime.minusDuration

FUNCTION DateTime.minusDuration(self: DateTime,
duration: Duration): DateTime

Subtract a Duration from a DateTime and return a new DateTime.

DateTime.minusPeriod

FUNCTION DateTime.minusPeriod(self: DateTime,
period: Period): DateTime

Subtract a Period from a DateTime and return a new DateTime.

DateTime.plusDuration

FUNCTION DateTime.plusDuration(self: DateTime,
duration: Duration): DateTime

Add a Duration to a DateTime and return a new DateTime.

DateTime.plusPeriod

FUNCTION DateTime.plusPeriod(self: DateTime,
period: Period): DateTime

Add a Period to a DateTime and return a new DateTime.

DateTime.toString

FUNCTION DateTime.toString(self: DateTime): String

Return an ISO 8601 formatted representation of a DateTime.

DateTime.withDate

FUNCTION DateTime.withDate(self: DateTime,
 year,
 month,
day: Number): DateTime

Return a new DateTime with the given year, month, and day based on an existing DateTime.

DateTime.withYear

FUNCTION DateTime.withYear(self: DateTime,
year: Number): DateTime

Return a new DateTime with the given year based on an existing DateTime.

DateTime.withMonth

FUNCTION DateTime.withMonth(self: DateTime,
month: Number): DateTime

Return a new DateTime with the given month based on an existing DateTime.

DateTime.withDay

FUNCTION DateTime.withDay(self: DateTime,
day: Number): DateTime

Return a new DateTime with the given day based on an existing DateTime.

DateTime.withTime

FUNCTION DateTime.withTime(self: DateTime,
 hour,
 minute,
second: Number): DateTime

Return a new DateTime with the given hour, minute, and second based on an existing DateTime.

DateTime.withHour

FUNCTION DateTime.withHour(self: DateTime,
hour: Number): DateTime

Return a new DateTime with the given hour based on an existing DateTime.

DateTime.withMinute

FUNCTION DateTime.withMinute(self: DateTime,
minute: Number): DateTime

Return a new DateTime with the given minute based on an existing DateTime.

DateTime.withSecond

FUNCTION DateTime.withSecond(self: DateTime,
second: Number): DateTime

Return a new DateTime with the given second based on an existing DateTime.

FUNCTION now(): DateTime
Return the current timestamp as a DateTime.
Represents a particular instant in global time, broken down to components in UTC.
FUNCTION makeFromInstant(inst: Instant): DateTime
Convert a specific instant into a DateTime record.
FUNCTION makeFromParts(dt: DateTime): DateTime
Given timestamp parts, return a DateTime representing the instant.
FUNCTION makeFromString(s: String): DateTime
Make a DateTime from a string representation.
FUNCTION DateTime.minusDuration(self: DateTime,
duration: Duration): DateTime
Subtract a Duration from a DateTime and return a new DateTime.
Represents a specific amount of time measured in seconds.
FUNCTION DateTime.minusPeriod(self: DateTime,
period: Period): DateTime
Subtract a Period from a DateTime and return a new DateTime.
Represents an amount of time measured by components.
FUNCTION DateTime.plusDuration(self: DateTime,
duration: Duration): DateTime
Add a Duration to a DateTime and return a new DateTime.
FUNCTION DateTime.plusPeriod(self: DateTime,
period: Period): DateTime
Add a Period to a DateTime and return a new DateTime.
FUNCTION DateTime.toString(self: DateTime): String
Return an ISO 8601 formatted representation of a DateTime.
FUNCTION DateTime.withDate(self: DateTime,
 year,
 month,
day: Number): DateTime
Return a new DateTime with the given year, month, and day based on an existing DateTime.
FUNCTION DateTime.withYear(self: DateTime,
year: Number): DateTime
Return a new DateTime with the given year based on an existing DateTime.
FUNCTION DateTime.withMonth(self: DateTime,
month: Number): DateTime
Return a new DateTime with the given month based on an existing DateTime.
FUNCTION DateTime.withDay(self: DateTime,
day: Number): DateTime
Return a new DateTime with the given day based on an existing DateTime.
FUNCTION DateTime.withTime(self: DateTime,
 hour,
 minute,
second: Number): DateTime
Return a new DateTime with the given hour, minute, and second based on an existing DateTime.
FUNCTION DateTime.withHour(self: DateTime,
hour: Number): DateTime
Return a new DateTime with the given hour based on an existing DateTime.
FUNCTION DateTime.withMinute(self: DateTime,
minute: Number): DateTime
Return a new DateTime with the given minute based on an existing DateTime.
FUNCTION DateTime.withSecond(self: DateTime,
second: Number): DateTime
Return a new DateTime with the given second based on an existing DateTime.
Close