Using UTC for a calendar built from scratch

Let’s say I have to build a calendar from scratch in Angular or any other frontend framework. Considering the following points:

  • I can only use the native Date class.

  • It must allow users to select a date, which can be saved into their browser and loaded afterwards. The user can switch timezones, but the shown date must stay the same.

  • The selected value will be sent to a web service in a timezone agnostic format, such as DD-MM-YYYY.

Taking these points into account, I’ve decided the best option for the calendar would be to build the cells using UTC, and to expect / emit values in UTC as well. However, I’ve encountered an issue when integrating the calendar with other date components (such as datepickers), because they always reflect the date in the local timezone.

This made me think: is this really the best approach? Is there a more flexible solution?