Skip to Main Content
Customer Feedback

We love feedback from you on our products and the problems in your daily work that you would like us to solve. Please describe the challenge you're encountering and your desired outcome. Be as detailed as possible.

For technical issues or bugs please head to Support or our Developer Community. You can assign up to 20 votes in total. Thank you for your feedback.

Status explanation: 'Future Consideration' = Continuing to collect further feedback, not planned at this time. 'Investigating' = Prioritized for deeper customer and feasibility investigations ahead of planning development.

Categories Forms
Created by Guest
Created on Oct 16, 2024

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.

  • Guest
    Reply
    |
    Oct 16, 2024

    Additionally, after doing some more digging, it seems that there is actually an issue.
    Selecting the Danish language as default in Google Chrome results in the command:

    console.log(navigator.language);

    Result in the following language code:

    da

    Which means that it would never hit the date formats mentioned in the EPiServerFormsSamples.js:

    DateFormats: {
                  "en-us": {
                      "pickerFormat": "mm/dd/yy",
                      "friendlyFormat": "MM/dd/yyyy"
                  },
                  "sv-se": {
                      "pickerFormat": "yy-mm-dd",
                      "friendlyFormat": "yyyy-MM-dd"
                  },
                  "nb-no": {
                      "pickerFormat": "dd.mm.yy",
                      "friendlyFormat": "dd.MM.yyyy"
                  },
                  "da-dk": {
                      "pickerFormat": "dd-mm-yy",
                      "friendlyFormat": "dd-MM-yyyy"
                  },
                  "de-de": {
                      "pickerFormat": "dd.mm.yy",
                      "friendlyFormat": "dd.MM.yyyy"
                  },
                  "nl-nl": {
                      "pickerFormat": "d-m-yy",
                      "friendlyFormat": "d-M-yyyy"
                  },
                  "fi-fi": {
                      "pickerFormat": "d.m.yy",
                      "friendlyFormat": "d.M.yyyy"
                  },
                  "fr-fr": {
                      "pickerFormat": "dd/mm/yy",
                      "friendlyFormat": "dd/MM/yyyy"
                  }
                }