Options
All
  • Public
  • Public/Protected
  • All
Menu

Translate times between each other easier for cleaner code. I.e. Duration.fromMinutes(27).toSeconds(); !(DANGER) This should not be used with real Dates. In the real world, not every day has 24 hours, and time is weird. This is just a simple abstraction. If you want real time adding on Dates, use Moment or similar library.

Can be used for simple conversions, I recommend going from bigger to smaller because of floating point errors though i.e. Duration.fromDays().toSeconds(); I also recommend checking isForever for unique cases.

Hierarchy

  • Duration

Methods

add

Parameters

Returns Duration

isForever

  • isForever(): boolean

Returns boolean

multiply

Parameters

  • times: number

Returns Duration

toDays

  • toDays(): number

Returns number

toHours

  • toHours(): number

Returns number

toMilliseconds

  • toMilliseconds(): number

Returns number

toMinutes

  • toMinutes(): number

Returns number

toSeconds

  • toSeconds(): number

Returns number

Static between

Parameters

Returns Duration

Static forever

Returns Duration

Static fromDays

Parameters

  • days: number

Returns Duration

Static fromHours

Parameters

  • hours: number

Returns Duration

Static fromMilliseconds

  • fromMilliseconds(milliseconds: number): Duration

Parameters

  • milliseconds: number

Returns Duration

Static fromMinutes

  • fromMinutes(minutes: number): Duration

Parameters

  • minutes: number

Returns Duration

Static fromSeconds

  • fromSeconds(seconds: number): Duration

Parameters

  • seconds: number

Returns Duration

  • Inherited
  • Protected
  • Private
  • Static
  • Module
  • Object
  • Property
  • Function
  • Variable
  • Index
  • Type
  • Class
  • Interface
  • Enum
  • Constructor
  • Getter/Setter
Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.