Enable selection of datetime format on DateTime block in EPiServer.Forms
The current implementation of the DateTime element (found in the EpiServer.Forms.Samples package appears to be insufficient.
In the DateTimeElementBlock.js file, the logic used to determine the language format relies on the browser's language settings. However, this approach fails, as many Danish users have their browsers set to English (US by default, resulting in the language code en-US. This causes the jQuery date picker to display the wrong date format.
var _utilsSvc = epi.EPiServer.Forms.Utils,
language = navigator.language || navigator.userLanguage, // on iOS naviagtor.language is in lower case (ex: en-us
dateFormatSettings = epi.EPiServer.Forms.Samples.DateFormats[language.toLowerCase(] || epi.EPiServer.Forms.Samples.DateFormats["en-us"],
dateFormat = dateFormatSettings.pickerFormat;
A better solution would be to allow users to select the language format directly within the block itself. This would be a more modular and user-friendly approach, in line with best practices for Optimizely implementations.
