Hierarchy
- TDate
Properties
Readonly day
Day.
Example:
const date = new TDate(2021, 1, 20);
const day = date.day;
Readonly month
Month.
Example:
const date = new TDate(2021, 1, 20);
const month = date.month;
Readonly year
Year.
Example:
const date = new TDate(2021, 1, 20);
const year = date.year;
Methods
addDate
-
Add a date.
Example:
const date = new TDate(2021, 1, 20); const newDate = date.addDate(0, 1, 5);
Parameters
-
years: number
-
month: number
-
days: number
Returns TDate
-
after
afterOrEqual
asDatetime
-
Conversion to date and time.
Returns the date and time in the specified time zone or in the current one if the time zone is not specified (by default, the company’s time zone).
Example:const date = new TDate(2021, 1, 20); const time = new TTime(3, 15, 0, 0); const datetime = date.asDatetime(time);
Parameters
Returns TDatetime
before
beforeOrEqual
equal
format
-
Converts the date to the required format.
The default format is
YYYY-MM-DD
. Use the following options to format dates:YYYY
,y
is for the year.MM
is for the month with a leading zero.M
is for the month without a leading zero.DD
is for the day with a leading zero.D
is for the day without a leading zero.d
is for the day of the week. Example:const date = new TDate(2021, 1, 20); const formatDate = date.format();
Parameters
-
Optional format: undefined | string
Returns string
-
Date
This type has the following constructors:
new TDate(): TDate; new TDate(year: number, month: number, day: number): TDate;
This type is immutable, so mutation methods return the updated value without changing the original one.
const date = new TDate(2022, 2, 24); const newDate = date.addDate(0, 1, 5);
Note that the TDate type is not the same as the built-in JavaScript type
Date
. This type only stores information about the date, not about the time of day.