I am having some difficulties with timezones... I have a guest site user who is in GMT time. So, when apex is running, they have GMT+0 timezone. The salesforce user that sends them the link to the site does include a desired timezone, however. For this example, it is 'America/Chicago'.
Now, I grab available hours for the salesforce user that sent the link for the external user to use in the form of '8:00 AM' for example. I convert that to a time string like '1901-01-01 08:00:00' and then do DateTime.valueOf('1901-01-01 08:00:00'), and it becomes 8:00 am on that date due to being in GMT time.
And, in the controller, when I do Timezone.getTimeZone('America/Chicago') and then to tz.getOffset(availableHours) (where availableHours is the 8:00 am time from above that I made), I get -6 hours instead... It seems to be just defaulting to central standard time.
This becomes a huge annoyance when I pass date times in both CDT, and the available hours, which are in CST to another remote function, then trying to deal with getting them to the same timezone...
Does anyone have any ideas or advice on creating a date time string (like 1901-01-01 08:00:00), then applying the correct daylight savings time timezone offset to it when using a timezone like 'America/Chicago' instead of using standard time?
If I could stop the -6 hour offset from the beginning when I first make those datetimes before they go to my VF page and make it the correct -5 hour offset, I believe my problem will be solved.