Does LokiJS supports ISO-8601 date format?

389 Views Asked by At

When storing a date in ISO-8601 format (a string), will the date operators ($dteq, $dtgte, $dtlte) work out-of-the-box? Or all my children are cursed by javascript date?

Oddhinn Blessadur!

1

There are 1 best solutions below

1
On BEST ANSWER

Looking at the source on github (great thing about open source), no. I mean, $dteq works because it just delegates to a general purpose equality test, and the strings match, but $gte/$lte (there's no $dtgte/$dtlte but if I assume you meant those) will try to treat the strings as numbers, which won't work.

If you stored the dates as numbers (milliseconds-since-The-Epoch), that would work. Or of course, as Date instances.