I have a Date I'd like to edit which represents a time in a timezone other than the web browser's. I am using a Scheduler component to display appointment times to the user. These appointment times may be in a timezone other than the user's (i.e. the client's web browser's machine's time zone). A user in CDT (America/Chicago) may edit a Scheduler configured to present times in EDT (America/New_York). The Scheduler handles this nicely with separate "start" and "startTimezone" (and end/endTimezone) properties. This allows the Scheduler to correctly display dates from the Eastern timezone.
const MyDatePicker = (props) => {
const regularDateInCDT = new Date(2021, 4, 31, 7, 30);
const zonedDateInCDT = ZonedDate.fromLocalDate(startTimeInCentralTimezone, "America/Chicago");
const zonedDateInEDT = zonedDateInCentralTimezone.toTimezone("America/New_York");
console.log("This looks right:", zonedDateInEasternTimezone.toString()); // "Mon May 31 2021 08:30:00 GMT-0400 (EDT)" "EDT" is "America/New_York".
return <DateTimePicker value={zonedDateInEasternTimezone} />; // Nope! Throws an exception about requiring a Date. A ZoendDate is not a Date.
}
Essentially, what I'd like is a function that will convert "7:30 AM in web browser timezone" into some value that a DateTimePicker will display as 8:30 AM. (7:30 CDT is 8:30 EDT.) In this particular example, I could just add one hour, but I want something that will work with any arbitrary pair of timezones.
Have I explained what I'm trying to do sufficiently?