freifunk / openwifimap-api

OpenWiFiMap database and its api
40 stars 12 forks source link

added fallback for evaluation of date stamps for older javascript engine... #2

Closed andibraeu closed 11 years ago

andibraeu commented 11 years ago

...s

could you please take a look if that could be a workaround for us? If it is, we also could start db replication

andrenarchy commented 11 years ago

uhh, I'm cautious with date-routines as there are so many strange time zones out there. ;) Is there any documentation clarifying which date routines are present in which JS engine?

andibraeu commented 11 years ago

maybe we should normalize the date stamps to UTC/GMT as it now does by default/accident (I think, there should be an additional part after the 'Z' for the timezone offset)

I've never seen an iso timestamp with timezone offset so far within the openwifimap database, so we could use this timestamp function to normalize all values before writing them to the database object?

andrenarchy commented 11 years ago

Actually, the 'Z' means UTC and this did not happen by accident ;). The provided date has to be UTC which is (mostly) what the date validation is about... I'll check the situation again tomorrow.

andrenarchy commented 11 years ago

According to the ECMAScript 5 documentation, the following should work in the first line of isDate:

var date = (new Date( Date.parse(newDoc[field]) )).toISOString();

@andibraeu would you like to check this in your installation?

andibraeu commented 11 years ago

debian squeeze only provides ECMAScript 3, and with that version, Date.parse can't parse ISO timestamps. The function I included as workaround is from http://www.sitepoint.com/parsing-an-iso-datestamp/ I had to customize it, because they didn't deal with milliseconds.

andrenarchy commented 11 years ago

Wow, that's really old. I see 3 possibilities:

  1. you update to a more recent distro.
  2. you continue to maintain a branch with patches for squeeze (perhaps there are more to come).
  3. I merge your branch.

I feel a bit uncomfortable including fallback code for outdated distributions, but I'm open for discussion. What do others think about this? @cholin @booo

andibraeu commented 11 years ago

At the moment I'd prefer option 2, maybe later option 1 :-)

andrenarchy commented 11 years ago

OK, issue will be closed.