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

instructor add session: closing time text box gives an NaaN error on Safari #4950

damithc opened this Issue Mar 9, 2016 · 4 comments


None yet
4 participants
Copy link

damithc commented Mar 9, 2016

Reported by user


This comment has been minimized.

Copy link
Contributor Author

damithc commented Mar 9, 2016

Can someone with a safari browser confirm?


This comment has been minimized.

Copy link

wkurniawan07 commented Mar 9, 2016

Yup, it's a Safari-specific bug.


This comment has been minimized.

Copy link
Contributor Author

damithc commented Mar 9, 2016

Ok, someone using safari needs to fix it soon. Otherwise TEAMMATES is unusable for such users.

@damithc damithc added p.Urgent and removed p.High labels Mar 9, 2016


This comment has been minimized.

Copy link

Gisonrg commented Mar 9, 2016

Not sure why only Safari cannot see it, but here is a possible analysis and suggest fix:
In datepicker.js, we have defined:

var yesterday = today.setDate(today.getDate() - 1);
var tomorrow = today.setDate(today.getDate() + 1);

But setDate will actually return a number of milliseconds since 1 January 1970 (doc), so basically our yesterday and tomorrow will be two number instead of a Date object.

Now we pass tomorrow as a default date to initialize a datepicker. As the jQuery UI document suggests, if the defaultDate is a number, then it is a number of days from today (-1 means yesterday, +1 means tomorrow, etc.). Since tomorrow is a very big number (milliseconds since 1 January 1970), datepicker will try to use the tomorrow as a offset from today and create that new date, but it realized the offset is too much and the date is an "invalid date". It will then use a "new Date()" as the displayed date.

Here is a debug screenshot in the jQuery UI source code, you can see the date is a number and newDate is "Invalid Date"
screen shot 2016-03-10 at 00 00 47

That's why even if on chrome we can see the picker, the default date for end date is actually today and not tomorrow :P

So I guess if we either fix yesterday or tomorrow to make them a valid Date object and pass to datepicker, or we simply use the number format (-1 for yesterday, +1 for tomorrow) and pass it to datepicker as default date.
Basically, a simple fix like

    dateFormat: "dd/mm/yy",
    showOtherMonths: true,
    gotoCurrent: true,
    defaultDate: +1

works great

Not sure if my reasoning is correct, but it would fix the bug 😛 anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.