Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove date auto type conversions #5982

Merged
merged 1 commit into from Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/adapters/adapter.moment.js
Expand Up @@ -41,15 +41,15 @@ helpers.merge(adapter, moment ? {
} else if (!(value instanceof moment)) {
value = moment(value);
}
return value.isValid() ? +value : null;
return value.isValid() ? value.valueOf() : null;
},

format: function(time, format) {
return moment(time).format(format);
},

add: function(time, amount, unit) {
return +moment(time).add(amount, unit);
return moment(time).add(amount, unit).valueOf();
},

diff: function(max, min, unit) {
Expand All @@ -59,13 +59,13 @@ helpers.merge(adapter, moment ? {
startOf: function(time, unit, weekday) {
time = moment(time);
if (unit === 'isoWeek') {
return +time.isoWeekday(weekday);
return time.isoWeekday(weekday).valueOf();
}
return +time.startOf(unit);
return time.startOf(unit).valueOf();
},

endOf: function(time, unit) {
return +moment(time).endOf(unit);
return moment(time).endOf(unit).valueOf();
},

// DEPRECATIONS
Expand Down
4 changes: 2 additions & 2 deletions src/scales/scale.time.js
Expand Up @@ -574,8 +574,8 @@ module.exports = Scale.extend({
max = parse(timeOpts.max, me) || max;

// In case there is no valid min/max, set limits based on unit time option
min = min === MAX_INTEGER ? +adapter.startOf(+new Date(), unit) : min;
max = max === MIN_INTEGER ? +adapter.endOf(+new Date(), unit) + 1 : max;
min = min === MAX_INTEGER ? +adapter.startOf(Date.now(), unit) : min;
max = max === MIN_INTEGER ? +adapter.endOf(Date.now(), unit) + 1 : max;

// Make sure that max is strictly higher than min (required by the lookup table)
me.min = Math.min(min, max);
Expand Down