UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

66 lines (65 loc) 2.15 kB
/** * @module Utilities */ import type { ISerializable } from "../../../serde/contracts/_module-exports.js"; /** * The `TimeSpan` class is used for representing time interval. * `TimeSpan` cannot be negative. * * IMPORT_PATH: `"@daiso-tech/core/utilities"` * @group TimeSpan */ export declare class TimeSpan implements ISerializable<number> { private readonly milliseconds; private static secondInMilliseconds; private static minuteInMilliseconds; private static hourInMilliseconds; private static dayInMilliseconds; static deserialize(timeInMs: number): TimeSpan; private constructor(); serialize(): number; static fromMilliseconds(milliseconds: number): TimeSpan; static fromSeconds(seconds: number): TimeSpan; static fromMinutes(minutes: number): TimeSpan; static fromHours(hours: number): TimeSpan; static fromDays(days: number): TimeSpan; static fromTimeSpan(timeSpan: TimeSpan): TimeSpan; static fromDateRange(from: Date, to: Date): TimeSpan; addMilliseconds(milliseconds: number): TimeSpan; addSeconds(seconds: number): TimeSpan; addMinutes(minutes: number): TimeSpan; addHours(hours: number): TimeSpan; addDays(days: number): TimeSpan; addTimeSpan(timeSpan: TimeSpan): TimeSpan; subtractMilliseconds(milliseconds: number): TimeSpan; subtractSeconds(seconds: number): TimeSpan; subtractMinutes(minutes: number): TimeSpan; subtractHours(hours: number): TimeSpan; subtractDays(days: number): TimeSpan; subtractTimeSpan(timeSpan: TimeSpan): TimeSpan; multiply(value: number): TimeSpan; divide(value: number): TimeSpan; toMilliseconds(): number; toSeconds(): number; toMinutes(): number; toHours(): number; toDays(): number; /** * Will return endDate relative to a given `startDate` argument. * * @default * ```ts * new Date() * ``` */ toEndDate(startDate?: Date): Date; /** * Will return startDate relative to a given `endDate` argument. * * @default * ```ts * new Date() * ``` */ toStartDate(endDate?: Date): Date; }