Commit b6ea50a7 authored by Oleksandr Chernyi's avatar Oleksandr Chernyi Committed by Valentino Međimorec
Browse files

Issue #3033868 by tzandev, BlacKICEUA: Add option for custom date time format

parent 6d157967
Loading
Loading
Loading
Loading
+6 −1
Changes for js/drupal.single_datetime.es6.js: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@
          // Set the hour format.
          const formatTime = hourFormat === "12h" ? "h:i A" : "H:i";

          const customFormat = input.data('customFormat');

          const inline = input.data("inline");

          const mask = Boolean(input.data("mask"));
@@ -122,6 +124,9 @@
              input.data("allowTimes")
            );
          }
          if (typeof customFormat !== 'undefined') {
            format = customFormat;
          }

          $(`#${input.attr("id")}`).datetimepicker({
            format,
@@ -157,7 +162,7 @@
          }

          // Explicitly set locale. Does not work with passed variable
          // in setttings above.
          // in settings above.
          $.datetimepicker.setLocale(lang);
        });
    }
+7 −1
Changes for js/drupal.single_datetime.js: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -104,6 +104,8 @@
        // Set the hour format.
        var formatTime = hourFormat === "12h" ? "h:i A" : "H:i";

        var customFormat = input.data('customFormat');

        var inline = input.data("inline");

        var mask = Boolean(input.data("mask"));
@@ -125,6 +127,10 @@
          allowTimes = SingleDatetimeAllowTimes(input.data("allowedHours"), input.data("allowTimes"));
        }

        if (typeof customFormat !== 'undefined') {
          format = customFormat;
        }

        $("#" + input.attr("id")).datetimepicker({
          format: format,
          formatTime: formatTime,
@@ -159,7 +165,7 @@
        }

        // Explicitly set locale. Does not work with passed variable
        // in setttings above.
        // in settings above.
        $.datetimepicker.setLocale(lang);
      });
    }
+1
Changes for src/Element/SingleDateTime.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ class SingleDateTime extends FormElement {
      'data-inline' => !empty($element['#inline']) ? 1 : 0,
      'data-mask' => !empty($element['#mask']) ? 1 : 0,
      'data-datetimepicker-theme' => $element['#datetimepicker_theme'],
      'data-custom-format' => $element['#custom_format'] ?? NULL,
    ];

    // Year start.