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

val(date) modifies passed date instance #221

Open
vfonic opened this issue Dec 16, 2017 · 0 comments
Open

val(date) modifies passed date instance #221

vfonic opened this issue Dec 16, 2017 · 0 comments

Comments

@vfonic
Copy link

vfonic commented Dec 16, 2017

Hi,

I've just experienced this issue:

var time = date.toTimeString().split(' ')[0]; // get hour and minute (there are better ways to do this)
var sched = later.parse.recur().on(time).time();
var dayOfWeek = later.dayOfWeek.val(date); // NOTE this line might mess up your `date` instance

console.log(dayOfWeek); // 3
console.log(date); // { 2017-12-19T20:00:00.000Z dw: 3 }

The date instance got modified. Is this expected behavior? I continued using date below this code point and received errors. I expected that call to val() won't change my date instance.

It's because this line of code:

val: function(d) {
return d.dw || (d.dw = later.date.getDay.call(d)+1);
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant