HDateTime.toString() displays the correct timezone. However, it displays the wrong time. Consider the following code snippet
import { HDateTime } from "haystack-core";
const now = new Date().toISOString();
// 2023-10-12T23:53:04.861Z
console.log(now);
const value = HDateTime.make({
val: now,
tz: "America/New_York"
}).toString();
// 10/12/2023, 4:53:04 PM America/New_York
console.log(value);
The string value of "10/12/2023, 4:53:04 PM" is incorrect. The correct string should be "10/12/2023, 7:53:04 PM". I believe this is because toString() uses Date.toLocaleString(), which I am assuming is creating a locale string for the local system time.
|
public toString(): string { |
public toString(): string {
return (
this.date.toLocaleString() +
(this.timezone ? ` ${this.timezone}` : '')
)
}