Duration
Classluxon 的时长类,用于表示一段时间间隔(如 "2 小时 30 分钟")并支持时长间的加减、格式化
Signature
class Duration {
static fromMillis(): void
static fromObject(): void
static fromDurationLike(): void
static fromISO(): void
static fromISOTime(): void
static invalid(): void
static isDuration(): void
toFormat(): void
toHuman(): void
toObject(): void
toISO(): void
toISOTime(): void
toJSON(): void
toString(): void
toMillis(): void
valueOf(): void
plus(): void
minus(): void
mapUnits(): void
get(): void
set(): void
reconfigure(): void
as(): void
normalize(): void
rescale(): void
shiftTo(): void
shiftToAll(): void
negate(): void
removeZeros(): void
equals(): void
}Methods
- toFormat()
- toHuman()
- toObject()
- toISO()
- toISOTime()
- toJSON()
- toString()
- toMillis()
- valueOf()
- plus()
- minus()
- mapUnits()
- get()
- set()
- reconfigure()
- as()
- normalize()
- rescale()
- shiftTo()
- shiftToAll()
- negate()
- removeZeros()
- equals()
- fromMillis() — static
- fromObject() — static
- fromDurationLike() — static
- fromISO() — static
- fromISOTime() — static
- invalid() — static
- isDuration() — static
Examples
Duration.fromObject({ hours: 2, minutes: 30 }).toFormat('h:mm')Source
node_modules/.pnpm/@types+luxon@3.7.5/node_modules/@types/luxon/src/duration.d.ts:126