coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

Check for values in milliseconds #75

Closed JordanReiter closed 12 years ago

JordanReiter commented 12 years ago

Occasionally, a date value will get stored in milliseconds instead of seconds (I believe this may have something to do with persistence.sync.js). As it gets passed back and forth, the date can get mangled so that it is far, far in the future.

The easy solution is to just check the number. If it greater than 1000000000000, then it's almost certainly in ms. 1000000000000 seconds corresponds to Sep 26 33,658 AD (1000000000000 ms corresponds to Sep 08, 2001). If someone needs to address dates later than 31,000 years from now I suggest they roll their own version.