@@ -279,6 +279,8 @@ COMPONENT('datepicker', 'today:Set today;clear:Clear;firstday:-1', function(self
279
279
dt . setMinutes ( + ( time [ 1 ] || '0' ) ) ;
280
280
dt . setSeconds ( + ( time [ 2 ] || '0' ) ) ;
281
281
}
282
+ } else {
283
+
282
284
}
283
285
284
286
self . opt . scope && M . scope ( self . opt . scope ) ;
@@ -360,8 +362,8 @@ COMPONENT('datepicker', 'today:Set today;clear:Clear;firstday:-1', function(self
360
362
if ( self . opt . clock ) {
361
363
var cols = self . opt . ampm ? ' col-3' : ' col-2' ;
362
364
var timepicker = '<div class="{0}-time"><i class="ti ti-clock"></i><div class="{0}-select-wrapper{1}">{{ content }}</div></div>' . format ( cls , cols ) ;
363
- var selecthours = '<div class="{0}-selecticon"><select id="{0}-hours" class="{0}-hours">{{ options }}</select><i class="ti ti-angle-down"></i></div>' . format ( cls ) ;
364
- var selectminutes = '<div class="{0}-selecticon"><select id="{0}-minutes" class="{0}-minutes">{{ options }}</select><i class="ti ti-angle-down"></i></div>' . format ( cls ) ;
365
+ var selecthours = '<div class="{0}-selecticon"><select class="{0}-hours">{{ options }}</select><i class="ti ti-angle-down"></i></div>' . format ( cls ) ;
366
+ var selectminutes = '<div class="{0}-selecticon"><select class="{0}-minutes">{{ options }}</select><i class="ti ti-angle-down"></i></div>' . format ( cls ) ;
365
367
var selectampm = '' ;
366
368
367
369
var hoursopt = [ ] ;
@@ -385,7 +387,7 @@ COMPONENT('datepicker', 'today:Set today;clear:Clear;firstday:-1', function(self
385
387
}
386
388
387
389
if ( self . opt . ampm )
388
- selectampm = '<div class="{0}-selecticon ampm"><select id="{0}-ampm" class="{0}-ampm"><option value="am">AM</option><option value="pm">PM</option></select><i class="ti ti-angle-down"></i></div>' . format ( cls ) ;
390
+ selectampm = '<div class="{0}-selecticon ampm"><select class="{0}-ampm"><option value="am">AM</option><option value="pm">PM</option></select><i class="ti ti-angle-down"></i></div>' . format ( cls ) ;
389
391
390
392
selecthours = selecthours . args ( { options : hoursopt . join ( '' ) } ) ;
391
393
selectminutes = selectminutes . args ( { options : minutesopt . join ( '' ) } ) ;
@@ -625,6 +627,23 @@ COMPONENT('datepicker', 'today:Set today;clear:Clear;firstday:-1', function(self
625
627
626
628
value = new Date ( ( value || NOW ) . getTime ( ) ) ;
627
629
630
+ if ( self . opt . clock ) {
631
+ var hour = value . getHours ( ) ;
632
+ var minutes = value . getMinutes ( ) . toString ( ) . padStart ( 2 , '0' ) ;
633
+
634
+ self . find ( cls2 + '-minutes' ) . val ( minutes ) ;
635
+
636
+ if ( self . opt . ampm ) {
637
+ var hour12 = hour % 12 || 12 ;
638
+ var ampm = hour >= 12 ? 'pm' : 'am' ;
639
+
640
+ self . find ( cls2 + '-hours' ) . val ( hour12 . toString ( ) . padStart ( 2 , '0' ) ) ;
641
+ self . find ( cls2 + '-ampm' ) . val ( ampm ) ;
642
+ } else {
643
+ self . find ( cls2 + '-hours' ) . val ( hour . toString ( ) . padStart ( 2 , '0' ) ) ;
644
+ }
645
+ }
646
+
628
647
var output = self . calculate ( value . getFullYear ( ) , value . getMonth ( ) , value ) ;
629
648
var dom = self . find ( cls2 + '-date' ) ;
630
649
0 commit comments