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

Fix date handling compatibility with Safari #134

Merged
merged 1 commit into from Apr 18, 2017

Conversation

Projects
None yet
2 participants
@westonruter
Copy link
Contributor

westonruter commented Apr 17, 2017

I opened the customizer in Safari and I found:

[Error] TypeError: null is not an object (evaluating 'parsed[fieldName]') at (anonymous function) (customize-snapshots.js:774)

It looks like some logic from Customize Posts was adopted before fixes for its Safari issues were implemented. See:
xwp/wp-customize-posts#293
xwp/wp-customize-posts#304

@westonruter westonruter added this to the 0.6.0 milestone Apr 17, 2017

@westonruter westonruter requested a review from sayedtaqui Apr 17, 2017

formattedDate += '-' + ( '00' + String( date.getDate() ) ).substr( -nonYearLength, nonYearLength );
formattedDate += ' ' + ( '00' + String( date.getHours() ) ).substr( -nonYearLength, nonYearLength );
formattedDate += ':' + ( '00' + String( date.getMinutes() ) ).substr( -nonYearLength, nonYearLength );
formattedDate += ':' + ( '00' + String( date.getSeconds() ) ).substr( -nonYearLength, nonYearLength );

This comment has been minimized.

@westonruter

westonruter Apr 17, 2017

Author Contributor

Being explicit about types just in case.

return parseInt( datePart, 10 );
} );
return new Date( dateParts[0], dateParts[1] - 1, dateParts[2], dateParts[3], dateParts[4], dateParts[5] ); // eslint-disable-line no-magic-numbers
},

This comment has been minimized.

@sayedtaqui

sayedtaqui Apr 18, 2017

Collaborator

I wish we could pass an array in the Date object, but one day we will be able to do it using spread syntax, like this, ( though it works in chrome ) 😀

return new Date(...dateParts);
timestampDifferential;

var snapshot = this, currentDate, currentTimestamp, timestampDifferential;
currentTimestamp = ( new Date() ).valueOf();

This comment has been minimized.

@sayedtaqui

sayedtaqui Apr 18, 2017

Collaborator

Just for my knowledge, thinking why you chose ( new Date() ).valueOf() over ( new Date() ).getTime();

This comment has been minimized.

@westonruter

westonruter Apr 18, 2017

Author Contributor

Good question. I don't have a particular reason. I just usually use it, as has the same output:

You can use this method to help assign a date and time to another Date object. This method is functionally equivalent to the valueOf() method.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime

I agree that getTime() would perhaps look more semantic.

@westonruter westonruter merged commit 28e0084 into develop Apr 18, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@westonruter westonruter deleted the fix/safari-date-handling branch Apr 18, 2017

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.