minotor
Version:
A lightweight client-side transit routing library.
108 lines (107 loc) • 4.04 kB
TypeScript
import { Duration } from './duration.js';
/**
* A class representing a time as minutes since midnight.
*/
export declare class Time {
private minutesSinceMidnight;
/**
* Gets the infinity time as a Time instance.
* This represents a time that is conceptually beyond any real possible time.
*
* @returns A Time instance representing an "infinity" time.
*/
static infinity(): Time;
/**
* Gets the midnight time as a Time instance.
*
* @returns A Time instance representing midnight.
*/
static origin(): Time;
private constructor();
/**
* Creates a Time instance from the number of minutes since midnight.
*
* @param minutes - The number of minutes since midnight.
* @returns A Time instance representing the specified time.
*/
static fromMinutes(minutes: number): Time;
/**
* Creates a Time instance from hours, minutes, and seconds.
* Rounds to the closest minute as times are represented in minutes from midnight.
*
* @param hours - The hours component of the time.
* @param minutes - The minutes component of the time.
* @param seconds - The seconds component of the time.
* @returns A Time instance representing the specified time.
*/
static fromHMS(hours: number, minutes: number, seconds: number): Time;
/**
* Creates a Time instance from hours, minutes.
*
* @param hours - The hours component of the time.
* @param minutes - The minutes component of the time.
* @returns A Time instance representing the specified time.
*/
static fromHM(hours: number, minutes: number): Time;
/**
* Parses a JavaScript Date object and creates a Time instance.
*
* @param date - A JavaScript Date object representing the time.
* @returns A Time instance representing the parsed time.
*/
static fromDate(date: Date): Time;
/**
* Parses a time string in the format "HH:MM:SS" or "HH:MM" and creates a Time instance.
*
* @param timeStr - A string representing the time in "HH:MM:SS" or "HH:MM" format.
* @returns A Time instance representing the parsed time.
*/
static fromString(timeStr: string): Time;
/**
* Converts the Time instance to a string in "HH:MM:SS" format.
*
* @returns A string representing the time.
*/
toString(): string;
/**
* Converts the Time instance to the total number of minutes since midnight, rounded to the closest minute.
*
* @returns The time in minutes since midnight.
*/
toMinutes(): number;
/**
* Adds a Duration to the current Time instance and returns a new Time instance.
*
* @param duration - A Duration instance representing the duration to add.
* @returns A new Time instance with the added duration.
*/
plus(duration: Duration): Time;
/**
* Subtracts a Duration from the current Time instance and returns a new Time instance.
*
* @param duration - A Duration instance representing the duration to subtract.
* @returns A new Time instance with the subtracted duration.
*/
minus(duration: Duration): Time;
/**
* Subtracts another Time instance from the current Time instance and returns the Duration.
*
* @param otherTime - A Time instance representing the time to subtract.
* @returns A Duration instance representing the time difference.
*/
diff(otherTime: Time): Duration;
/**
* Computes the maximum Time instance among the provided Time instances.
*
* @param times - An array of Time instances to compare.
* @returns A Time instance representing the maximum time.
*/
static max(...times: Time[]): Time;
/**
* Computes the minimum Time instance among the provided Time instances.
*
* @param times - An array of Time instances to compare.
* @returns A Time instance representing the minimum time.
*/
static min(...times: Time[]): Time;
}