Summary
DateTimeUtils.UTCToString is named and documented as returning a UTC time string, but it returns the local-timezone string via Date.prototype.toTimeString(). Anyone consuming this output has to know to ignore the function name, and tests/CI on machines in different timezones can produce different results.
Affected code
lib/DateTimeUtils.ts:3-7
public static UTCToString(UTCString: string) {
let utcDate = new Date();
utcDate.setUTCHours(+UTCString.substr(0, 2), +UTCString.substr(2, 2), 0);
return utcDate.toTimeString(); // <-- returns LOCAL time string
}
toTimeString() produces e.g. "08:30:00 GMT-0700 (Pacific Daylight Time)" for an input that was conceptually 15:30 UTC.
Suggested fix
Either return a UTC representation:
return utcDate.toUTCString();
// or, just the time portion:
return utcDate.toISOString().slice(11, 19);
…or rename the method if the local-time behavior is intentional.
Related smaller cleanup
The whole class uses String.prototype.substr(), which is a legacy/deprecated API. It still works but should be replaced with substring() or slice() for consistency with the rest of the codebase (convertHHMMSSToTod, convertDayTimeToTod, etc., already use substring). Affected: UTCToString, UTCDateTimeToString.
Summary
DateTimeUtils.UTCToStringis named and documented as returning a UTC time string, but it returns the local-timezone string viaDate.prototype.toTimeString(). Anyone consuming this output has to know to ignore the function name, and tests/CI on machines in different timezones can produce different results.Affected code
lib/DateTimeUtils.ts:3-7toTimeString()produces e.g."08:30:00 GMT-0700 (Pacific Daylight Time)"for an input that was conceptually 15:30 UTC.Suggested fix
Either return a UTC representation:
…or rename the method if the local-time behavior is intentional.
Related smaller cleanup
The whole class uses
String.prototype.substr(), which is a legacy/deprecated API. It still works but should be replaced withsubstring()orslice()for consistency with the rest of the codebase (convertHHMMSSToTod,convertDayTimeToTod, etc., already usesubstring). Affected:UTCToString,UTCDateTimeToString.