日期处理#
本文档列出了内置的便捷函数,用于支持在表达式中进行日期数据转换。
表达式中的 JavaScript
您可以在表达式中使用任何 JavaScript 代码。更多信息请参考表达式。
beginningOf(unit?: DurationUnit): Date #
Transforms a Date to the start of the given time period. Returns either a JavaScript Date or Luxon Date, depending on input.
Function parameters#
unitOptionalString enum
A valid string specifying the time unit.
endOfMonth(): Date #
Transforms a Date to the end of the month.
extract(datePart?: DurationUnit): Number #
Extracts the part defined in datePart from a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
Function parameters#
datePartOptionalString enum
A valid string specifying the time unit.
format(fmt: TimeFormat): String #
Formats a Date in the given structure
Function parameters#
fmtRequiredString enum
A valid string specifying the time format. Refer to Luxon | Table of tokens for formats.
isBetween(date1: Date | DateTime, date2: Date | DateTime): Boolean #
Checks if a Date is between two given dates.
Function parameters#
date1RequiredDate or DateTime
The first date in the range.
date2RequiredDate or DateTime
The last date in the range.
isDst(): Boolean #
Checks if a Date is within Daylight Savings Time.
isInLast(n?: Number, unit?: DurationUnit): Boolean #
Checks if a Date is within a given time period.
Function parameters#
nOptionalNumber
The number of units. For example, to check if the date is in the last nine weeks, enter 9.
unitOptionalString enum
A valid string specifying the time unit.
isWeekend(): Boolean #
Checks if the Date falls on a Saturday or Sunday.
minus(n: Number, unit?: DurationUnit): Date #
Subtracts a given time period from a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
Function parameters#
nRequiredNumber
The number of units. For example, to subtract nine seconds, enter 9 here.
unitOptionalString enum
A valid string specifying the time unit.
plus(n: Number, unit?: DurationUnit): Date #
Adds a given time period to a Date. Returns either a JavaScript Date or Luxon Date, depending on input.
Function parameters#
nRequiredNumber
The number of units. For example, to add nine seconds, enter 9 here.
unitOptionalString enum
A valid string specifying the time unit.
toDateTime(): Date #
Converts a JavaScript date to a Luxon date object.