geolexica / isotc211-glossary

ISO/TC 211 MLGT Online Concepts
2 stars 8 forks source link

Fix shifted dates #17

Closed skalee closed 4 years ago

skalee commented 4 years ago

Dates were incorrectly shifted by 1 day.

Unfortunately, dates are stored as timestamps, which is error-prone, as one may forget about time zones.

The story behind is that Hong Kong time zone is UTC+8, and when these timestamps have been converted to UTC, they have been effectively shifted by 8 hours, that is to 4 PM previous day.

In this very commit dates are fixed with following command:

ruby -rtime -p -i -e '$_.sub!(/\S*T16:00:00.000Z/) { |d| t = Time.parse(d); t += 8 * 3600; t.iso8601(3) }' concept-*.yaml
strogonoff commented 4 years ago

Makes sense, this looks like a ticket for the desktop software which should apply current user’s local timezone adjustment when storing timestamps in Zulu/UTC (I think it currently doesn’t)

skalee commented 4 years ago

@strogonoff Commit message has been updated.

Dates should be stored as calendar dates, not as timestamps. Yes, this is a legacy issue which comes from spreadsheet parsers, they used to produce timestamps as well. In fact, I had to set shell variable TZ=Asia/Hong_Kong to avoid cluttered diffs.

I have no clue how it affects Glossarist, so I definitely don't merge it myself. Please do whatever you think is best.

skalee commented 4 years ago

Just did following to prove that there are no other shifted timestamps (i.e. in this pull request all timestamps contain T00:00:00.000Z)

grep -oh '\S\+.000Z' concept-*.yaml | sort | uniq
ronaldtse commented 4 years ago

Let's merge this to fix the data, and fix the app separately.