Timesheet bug fix

We received reports from multiple users about a bug in the time sheet feature. When users were recording hours, the date would shift days from the one they selected. Today we've deployed a fix for this!

This was timezone-related bug in our frontend Javascript code. The date picker component in our code returned a Date object of midnight in the local timezone. To convert it to the ISO day format that we use in the API, we originally used this code:

const date = val.toISOString().substring(0, 10);    

The issue is that the toISOString method converts the Date to the UTC timezone. This means that the calendar day may change!

The fix was to account for the UTC offset when calculating the date:

const dt = new Date(val);
dt.setMinutes(dt.getMinutes() - dt.getTimezoneOffset());
const date = dt.toJSON().slice(0, 10);

Screen Shot 2018-07-03 at 11.57.43 AM.png