Hierarchy
- TTime
Properties
Readonly hours
Number of hours.
Example:
const time = new TTime(3, 15, 0, 0);
const hours = time.hours;
Readonly milliseconds
Number of milliseconds.
Example:
const time = new TTime(3, 15, 0, 0);
const milliseconds = time.milliseconds;
Readonly minutes
Number of minutes.
Example:
const time = new TTime(3, 15, 0, 0);
const minutes = time.minutes;
Readonly seconds
Number of seconds.
Example:
const time = new TTime(3, 15, 0, 0);
const seconds = time.seconds;
Methods
add
-
Add time.
Example:
const time = new TTime(3, 15, 0, 0); const duration = new Duration(100, 'millisecond'); const newTime = time. add(duration);
If you set hours to more than 24, the system will subtract 24 , and the new time will be calculated starting from midnight.
Parameters
-
duration: TDuration
Returns TTime
-
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 time = new TTime(3, 15, 0, 0); const date = new TDate(2021, 1, 20); const datetime = time.asDatetime(date);
Parameters
Returns TDatetime
before
beforeOrEqual
equal
format
-
Coverts the time to the required format.
The default format is
HH:mm:ss
. Use the following options to format time:HH
is for hours in the 24-hour time format.hh
is for hours in the 12-hour time format.mm
is for minutes.ss
is for seconds.SSS
is for milliseconds. Example:const time = new TTime(13, 15, 0, 0); const formatTime = time.format('hh mm'); // 1pm 15
Parameters
-
Optional format: undefined | string
Returns string
Time
Stores time not exceeding 24 hours. This type has the following constructors:
new TTime(): TTime; new TTime(duration: TDuration): TTime; new TTime(hours: number, minutes: number, seconds: number, milliseconds: number): TTime;
This type is immutable, so mutation methods return the updated value without changing the original one.
const time = new TTime(3, 15, 0, 0); const newTime = time.add(2, 15, 0, 0); newTime.after(time); // true