Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jul 24, 2015 @ 18:07
    Bo Damgaard Mortensen
    0

    Timepicker in property editor ignoring 24h config setting

    Hi all,

    I'm building a custom property editor for handling shops opening hours. For this, I want to make use of the built-in Timepicker (datepicker property editor with the date-part disabled)

    I've got it working and the timepickers (there are one for opening hour and one for closing hour) displays fine on the editor. However, i can't get it to use 24 hours instead of 12 hours AM/PM.

    My code is as follows:

    angular.module("umbraco").controller("openingHours.controller", function ($scope, assetsService) {
        // New, reusable time picker object
        var timePicker = {
            view: 'datepicker',
            config: {
                pickDate: false,
                pickTime: true,
                pick12HourFormat: false,
                time24h: true,
                format: "hh:mm"
            },
            value: new Date()
        };
    
        // Add fields for each day if the model value is empty
        if ($scope.model.value === "") {
            $scope.model.value.weekDays.push({ DayOfWeek: "Monday", Label: "Mandag", Open: timePicker, Closed: timePicker, ClosedThisDay: false });
            // .. rest of adding is omitted
        }
    }
    

    (I know I could just go with one regular property for each day in the week, but this is a bit more complex than that :-))

    I've cleared browser cache and everything, but it still won't let me select i.e. 13:00 I'm suspecting that some kind of localisation is needed somewhere? If I add a datpicker with time on a regular property, the time is set to 24h by default.

    Anyone knows what I'm missing here?

    Thanks in advance :-)

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jul 24, 2015 @ 18:17
    Bo Damgaard Mortensen
    100

    Update:

    Setting the format to format: "HH:mm" made it use the 24h format ;-) Time for a break, me thinks....

Please Sign in or register to post replies

Write your reply to:

Draft