Skip to main content

TimeResolvable

type TimeResolvable = HolyTime | Date | number | string
Union type representing any value that can be resolved to a time. Accepted values:
  • HolyTime - A HolyTime instance
  • Date - A JavaScript Date object
  • number - A timestamp in milliseconds
  • string - A date string parseable by the Date constructor
Example:
const time1 = new HolyTime('2024-01-01')
const time2 = new HolyTime(new Date())
const time3 = new HolyTime(1704067200000)
const time4 = new HolyTime(existingHolyTimeInstance)

DurationResolvable

type DurationResolvable = HolyDuration | number
Union type representing any value that can be resolved to a duration. Accepted values:
  • HolyDuration - A HolyDuration instance
  • number - A duration in milliseconds
Example:
const duration1 = new HolyDuration(60000)
const duration2 = new HolyDuration(existingDuration)

HumanUnit

type HumanUnit = `${Lowercase<keyof typeof TimeUnits>}s`
String literal type for plural time unit names. Valid values:
  • 'milliseconds'
  • 'seconds'
  • 'minutes'
  • 'hours'
  • 'days'
  • 'weeks'
  • 'months'
  • 'years'
Example:
HolyTime.add(new Date(), 5, 'minutes')
HolyTime.add(new Date(), 2, 'hours')
HolyTime.duration(30, 'seconds')

IntervalUnit

type IntervalUnit =
  | 'millisecond'
  | 'second'
  | 'minute'
  | 'hour'
  | 'day'
  | 'week'
  | 'month'
  | 'year'
String literal type for singular time interval unit names. Used for operations like startOf(), endOf(), and isSame(). Valid values:
  • 'millisecond'
  • 'second'
  • 'minute'
  • 'hour'
  • 'day'
  • 'week'
  • 'month'
  • 'year'
Example:
HolyTime.startOf('day')
HolyTime.endOf('month')
time.isSame(otherTime, 'hour')

GetUnit

type GetUnit = `${Lowercase<keyof typeof TimeUnits>}`
String literal type for singular time unit names. Used for getting and setting individual time components. Valid values:
  • 'millisecond'
  • 'second'
  • 'minute'
  • 'hour'
  • 'day'
  • 'week'
  • 'month'
  • 'year'
Example:
const hour = time.get('hour')
time.set('minute', 30)
const allComponents = time.get('object')

Build docs developers (and LLMs) love