Skip to content

Commit c82fc3a

Browse files
committed
v2.3.0
1 parent 227dd63 commit c82fc3a

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ bower_components
33
node_modules
44
.sass-cache
55
.vscode
6+
/coverage

dist/material-datetime-picker.js

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/material-datetime-picker.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/material-datetime-picker.mjs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,18 @@ var DateTimePicker = function (_Events) {
304304
this.pmToggleEl = this.$('.c-datepicker__clock--pm');
305305

306306
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);
308317
}
309318

310-
this.setDate(this.value);
311-
this.setTime(this.value);
312319
this.initializeRome(this.$('.' + this.options.styles.container), this.options.dateValidator);
313320
this._show();
314321
}
@@ -557,8 +564,14 @@ var DateTimePicker = function (_Events) {
557564
}, {
558565
key: 'data',
559566
value: function data(val) {
567+
console.warn('MaterialDatetimePicker#data is deprecated and will be removed in a future release. Please use get or set.');
560568
return val ? this.set(val) : this.value;
561569
}
570+
}, {
571+
key: 'get',
572+
value: function get$$1() {
573+
return moment(this.value);
574+
}
562575

563576
// update the picker's date/time value
564577
// value: moment
@@ -578,7 +591,9 @@ var DateTimePicker = function (_Events) {
578591
if (m.date() !== this.value.date() || m.month() !== this.value.month() || m.year() !== this.value.year()) {
579592
this.setDate(m);
580593
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()) {
582597
this.setTime(m);
583598
evts.push('change:time');
584599
}
@@ -628,7 +643,7 @@ var DateTimePicker = function (_Events) {
628643
key: 'setTime',
629644
value: function setTime(time) {
630645
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;
632647
m.minutes(minuteAsInt);
633648

634649
var hour = m.format('HH');

dist/material-datetime-picker.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "material-datetime-picker",
3-
"version": "2.2.0",
3+
"version": "2.3.0",
44
"description": "A Vanilla JS Material Design date/time picker component",
55
"main": "dist/material-datetime-picker.js",
66
"module": "dist/material-datetime-picker.mjs",

0 commit comments

Comments
 (0)