Refactor ISOToDateTime to handle case when timezone's server is UTC

A condition is added to check if the timezone is set as '0000' (UTC timezone), if yes then a new Date is returned with the Date.UTC method. This ensures that the time returned correctly reflects the current timezone
This commit is contained in:
Julien Fastré 2024-06-01 00:40:22 +02:00
parent ab5f2ffb65
commit 84ce8a93f3
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -59,6 +59,10 @@ export const ISOToDatetime = (str: string|null): Date|null => {
[hours, minutes, seconds] = time.split(':').map(s => parseInt(s));
;
if ('0000' === timezone) {
return new Date(Date.UTC(year, month-1, date, hours, minutes, seconds));
}
return new Date(year, month-1, date, hours, minutes, seconds);
}