From 9784b50c505e51e6daf2654b663cded59b2bd3c8 Mon Sep 17 00:00:00 2001 From: Valerii Sidorenko Date: Wed, 24 Apr 2024 16:48:15 +0200 Subject: [PATCH] fix(Duration): humanize should not depend on DST (#56) --- src/duration/duration.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/duration/duration.ts b/src/duration/duration.ts index 66bc3cc..b7adb16 100644 --- a/src/duration/duration.ts +++ b/src/duration/duration.ts @@ -1,7 +1,7 @@ // Copyright 2019 JS Foundation and other contributors // Copyright 2024 YANDEX LLC -import {dateTime} from '../dateTime'; +import {dateTimeUtc} from '../dateTime'; import {settings} from '../settings'; import type {Duration, DurationInput, DurationInputObject, DurationUnit} from '../typings'; import {normalizeDateComponents, normalizeDurationUnit} from '../utils'; @@ -288,7 +288,8 @@ export class DurationImpl implements Duration { if (!this.isValid()) { return 'Invalid Duration'; } - return dateTime({lang: this._locale}).add(this.valueOf(), 'ms').fromNow(!withSuffix); + const now = dateTimeUtc({lang: this._locale}); + return now.add(this.valueOf(), 'ms').from(now, !withSuffix); } humanizeIntl(