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
Constructors:
new TDate(): TDate; new TDate(year: number, month: number, day: number): TDate;
alues of this type are immutable, so mutation methods return an updated value without modifying the original.
const date = new TDate(2022, 2, 24); // 2022-02-24 const newDate = date.addDate(0, 1, 5); // 2022-03-29
Note that the type TDate оdiffers from the built-in JavaScript type
Date
. This type contains only date information, without the time of day.