ebs.InvariantDate
JSON object that stores a date in a culture-invariant format.
Syntax
Copy
class ebs.InvariantDate(inputDate)
| Parameter | Description |
|---|---|
inputDate
|
Date object or string representing a date. Eg:
|
Return Value
Returns a JSON object that contains the date in culture-invariant format (in the form: {"invariantDate":"2020-01-23"}).
Properties
| Property | Returned Type | Description |
|---|---|---|
day
|
number | The day component of the date, expressed as a value between 1 and 31. |
dayOfWeek
|
number | The day of the week, expressed as a value between 1 (Monday) and 7 (Sunday). |
dayOfYear
|
number | The day of the year, expressed as a value between 1 and 366. |
month
|
number | The month component of the date, expressed as a value between 1 and 12. |
today
|
InvariantDate | The current date. |
year
|
number | The year component of the date. |
weekOfYear FintechOS 21.2.0 and later |
number | The week of the year, expressed as a value between 1 and 53 |
Methods
| Method | Returned Type | Description |
|---|---|---|
addDays(number)
|
InvariantDate | Adds the specified number of days to the value of the instance and returns the instance. Negative values subtract the specified number of days (dates prior to 0001-01-01 are not supported). |
addMonths(number)
|
InvariantDate | Adds the specified number of months to the value of the instance and returns the instance. Negative values subtract the specified number of months (dates prior to 0001-01-01 are not supported). NOTE The day component of the date is "rounded down". For instance, adding one month to 2020-03-31 will return 2020-04-30. |
addYears(number)
|
InvariantDate | Adds the specified number of years to the value of the instance and returns the instance. Negative values subtract the specified number of years (dates prior to 0001-01-01 are not supported). NOTE The day component of the date is "rounded down". For instance, adding one year to 2020-02-29 will return 2021-02-28. |
toString()
|
string | Returns a string representation of the instance's value in "yyyy-mm-dd" format. |
getEndOfMonth(date: InvariantDate) FintechOS 21.2.0 and later |
InvariantDate | Returns an invariant date matching the last day from the month of the input date. |
dateDiff(datePart: string, startDate: InvariantDate, endDate: InvariantDate) FintechOS 21.2.0 and later |
number | Returns the number of days, weeks, months, quarters, or years between the startDate and endDate, depending on the dateDiff parameter. Supported values for the dateDiff parameter are: "Day", "Week", "Month", "Quarter", and "Year". |
Examples
In this example:
- We define a new invariant date variable called x that stores the current day.
- We use the day property to extract the day component from the date.
- We display the day on screen. For details on how to display messages, see ebs.showMessage.
Copy
let x = new ebs.InvariantDate(new Date)
ebs.showMessage(x.day.toString())
In this example
- We use the today property to generate the current date.
- We use the addDays method to add 100 days to the current date.
- We use the toString method to generate the string representation of the target date.
- We display the day on screen. For details on how to display messages, see ebs.showMessage.
Copy
ebs.showMessage(ebs.InvariantDate.today.addDays(100).toString())