matcher/src/modules/ad/domain/entities/time-converter.ts

17 lines
405 B
TypeScript
Raw Normal View History

2023-05-02 09:56:07 +00:00
import { DateTime, TimeZone } from 'timezonecomplete';
export class TimeConverter {
static toUtcDatetime = (
date: string,
time: string,
ianaTimezone: string,
): Date =>
date && time
? new Date(
new DateTime(`${date}T${time}:00`, TimeZone.zone(ianaTimezone, false))
.convert(TimeZone.zone('UTC'))
.toIsoString(),
)
: undefined;
}