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.

Hierarchy

  • TDate

Properties

Readonly day

day: number

Day.

Example:

const date = new TDate(2021, 1, 20);
const day =  date.day; 

Readonly month

month: number

Month.

Example:

const date = new TDate(2021, 1, 20);
const month =  date.month; 

Readonly year

year: number

Year.

Example:

const date = new TDate(2021, 1, 20);
const year =  date.year; 

Methods

addDate

  • addDate(years: number, month: number, days: number): TDate
  • 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

  • Checks whether the specified date is later than another.

    Example:

    const startDate = new TDate(2021, 1, 20);
    const  endDate = new TDate(2021, 1, 21); 
    const after = startDate.after(endDate); //  false 
    

    Parameters

    Returns boolean

afterOrEqual

  • Checks whether the current date is the same as or later than date.

    Example:

    const startDate = new TDate(2021, 1, 20);
    const  endDate = new TDate(2021, 1, 21); 
    const equal = startDate. afterOrEqual(endDate); // false 
    

    Parameters

    Returns boolean

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

  • Checks whether the specified date is earlier than another.

    Example:

    const startDate = new TDate(2021, 1, 20);
    const  endDate = new TDate(2021, 1, 21); 
    const before = startDate.before(endDate); //  true 
    

    Parameters

    Returns boolean

beforeOrEqual

  • Checks whether the current date is the same as or earlier than date.

    Example:

    const startDate = new TDate(2021, 1, 20);
    const  endDate = new TDate(2021, 1, 21); 
    const equal = startDate. beforeOrEqual(endDate); // true 
    

    Parameters

    Returns boolean

equal

  • Checks whether two date objects have the same value.

    Example:

    const startDate = new TDate(2021, 1, 20);
    const  endDate = new TDate(2021, 1, 21); 
    const equal = startDate.equal(endDate); //  false 
    

    Parameters

    Returns boolean

format

  • format(format?: undefined | string): string
  • 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