couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Ramage <ryan.ram...@gmail.com>
Subject Re: map timezones
Date Wed, 06 Mar 2013 06:51:35 GMT
Yes, date stuff in js can be a pain. That's why lately I turn to moment.js

http://momentjs.com/

It can run browser, node, and in couchdb map, show and list functions using
require. It will alleviate many headaches. It will do many of the fun math
ops.

That being said, I prefer to store millisecond timestamps. Some other like
storing utc strings as they are easier to look at when browsing docs.
Then only do the final conversion to a printable date on display.
On Mar 5, 2013 11:13 PM, "Will Heger" <will.heger@gmail.com> wrote:

> So, let's say that I stamp documents with UTC or epoch values when
> recording time values.
>
> Eventually, I will need to do reporting and math on these values using
> local time.  Now if there existed a function like...
>
> Date(stamp).localTime("New York")
>
> ...that would yield a deterministic result, so it's Kosher for Couch.  The
> underlying math would be either UTC-5 or UTC-4 depending on the year and US
> law, but the mapped output would be predictable.
>
> That said, I don't think such an animal exists in default JS.  The
> getTimezoneOffset() assumes the browser's time which is fraught. Firstly, I
> might need "Los Angeles" time and not "New York" time and that can't depend
> on where my CouchDB server is installed. Also I need a map that's aware of
> EDT vs EST on a historical basis so that a a particular UTC value in 1995
> when daylight savings time switchover was at a different hour is captured.
>
> Anyway, I can make sure to convert times inbound which loses other
> reporting functionality like timechange sensitive math or I could store
> both at the cost of an extra field.
>
> Any pointers?
>
> Thanks,
> -Will
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message