@@ -304,11 +304,18 @@ var DateTimePicker = function (_Events) {
304
304
this . pmToggleEl = this . $ ( '.c-datepicker__clock--pm' ) ;
305
305
306
306
if ( ! this . value ) {
307
- this . value = moment ( this . options . default ) ;
307
+ // TODO hack
308
+ // set/setDate/setTime need refactoring to have single concerns
309
+ // (set: set the value; setDate/setTime rename to renderDate/renderTime
310
+ // and deal with updating the view only).
311
+ // For now this allows us to set the default time using the same quantize
312
+ // rules as setting the date explicitly. Setting this.value meets setTime|Date's
313
+ // expectation that we have a value, and `0` guarantees that we will detect
314
+ this . value = moment ( 0 ) ;
315
+ this . setDate ( this . options . default ) ;
316
+ this . setTime ( this . options . default ) ;
308
317
}
309
318
310
- this . setDate ( this . value ) ;
311
- this . setTime ( this . value ) ;
312
319
this . initializeRome ( this . $ ( '.' + this . options . styles . container ) , this . options . dateValidator ) ;
313
320
this . _show ( ) ;
314
321
}
@@ -557,8 +564,14 @@ var DateTimePicker = function (_Events) {
557
564
} , {
558
565
key : 'data' ,
559
566
value : function data ( val ) {
567
+ console . warn ( 'MaterialDatetimePicker#data is deprecated and will be removed in a future release. Please use get or set.' ) ;
560
568
return val ? this . set ( val ) : this . value ;
561
569
}
570
+ } , {
571
+ key : 'get' ,
572
+ value : function get$$1 ( ) {
573
+ return moment ( this . value ) ;
574
+ }
562
575
563
576
// update the picker's date/time value
564
577
// value: moment
@@ -578,7 +591,9 @@ var DateTimePicker = function (_Events) {
578
591
if ( m . date ( ) !== this . value . date ( ) || m . month ( ) !== this . value . month ( ) || m . year ( ) !== this . value . year ( ) ) {
579
592
this . setDate ( m ) ;
580
593
evts . push ( 'change:date' ) ;
581
- } else if ( m . hour ( ) !== this . value . hour ( ) || m . minutes ( ) !== this . value . minutes ( ) ) {
594
+ }
595
+
596
+ if ( m . hour ( ) !== this . value . hour ( ) || m . minutes ( ) !== this . value . minutes ( ) ) {
582
597
this . setTime ( m ) ;
583
598
evts . push ( 'change:time' ) ;
584
599
}
@@ -628,7 +643,7 @@ var DateTimePicker = function (_Events) {
628
643
key : 'setTime' ,
629
644
value : function setTime ( time ) {
630
645
var m = moment ( time ) ;
631
- var minuteAsInt = Math . ceil ( parseInt ( m . format ( 'mm' ) , 10 ) / 5 ) * 5 ;
646
+ var minuteAsInt = Math . round ( parseInt ( m . format ( 'mm' ) , 10 ) / 5 ) * 5 ;
632
647
m . minutes ( minuteAsInt ) ;
633
648
634
649
var hour = m . format ( 'HH' ) ;
0 commit comments