add a comment about mis-detecting DateJS dates as locales

This commit is contained in:
Sami Samhuri 2016-12-27 10:57:37 -08:00
parent 65aa4d5ea9
commit 2294caa44b
No known key found for this signature in database
GPG key ID: F76F41F04D99808F

View file

@ -74,6 +74,11 @@
adaptForwards(adaptedStrftime); adaptForwards(adaptedStrftime);
function adaptedStrftime(fmt, d, locale) { function adaptedStrftime(fmt, d, locale) {
// d and locale are optional, check if this is (format, locale) // d and locale are optional, check if this is (format, locale)
//
// `days` is required on all locales, but DateJS modifies `Date` objects and gives them
// a `days` property. We check that the second parameter doesn`t have `getTime`, which
// should never appear in a locale object, before concluding that `d` is in fact a
// locale object and not a date.
if (d && d.days && !d.getTime) { if (d && d.days && !d.getTime) {
locale = d; locale = d;
d = undefined; d = undefined;