I am trying to get appointments that are saved with UTC times filtered by e.g. the date. The problem is an appointment can be saved for UTC June 1st 10:00 PM, but when the user is located in Germany, that would be June 2nd 12:00 AM for that user's local time. When the user requests all appointments for June 1st that appointment should not appear, but when June 2nd is requested, it should.
As long as the backend doesn't know which timezone to apply, it will behave the other way around.
I am aware of ToLocalTime() in the backend, but as for my understanding that will only behave correctly as long as the client is in the same timezone as the server.
One might say, that I could use getTimezoneOffset() on the client side and pass it to the backend in some way. But that won't work, because of daylight savings.
UTC December 1st 10:00 PM would result in a German local time of December 1st 11:00 PM, so applying the current timezone offset doesn't help.
I figured out, that most browsers will support Intl.DateTimeFormat().resolvedOptions().timeZone to get the timezone as a text. But passing that one to the backend didn't help either, because when I check the list of supported timezones returned by TimeZoneInfo.GetSystemTimeZones() in the backend, I can't find the same string as the browser provides. (browser returns 'Europe/Berlin', Id in backend is 'W. Europe Standard Time', other strings are even localized)
I know that I'm exhausted a bit, because working with dates and times was a reoccuring theme for me today, but am I missing out on something obvious? What can I do to make the backend aware of the relevant timezone? And how would I get the DateTime for that specific timezone?