rdf-ext / rdf-parser-csvw

CSV on the Web parser
MIT License
16 stars 4 forks source link

Date mapping is off by one day #14

Closed ktk closed 5 years ago

ktk commented 5 years ago

In the BLV pipeline I have date fields in the form: 14.05.2018, we map it to RDF with the following mapping:

    "datatype": {
      "base": "date",
      "format": "dd.MM.yyyy"
    }

This results in the following RDF output: "2018-05-13"^^<http://www.w3.org/2001/XMLSchema#date>

So it is off by one day (in the past). I suspect this is some default timezone handling that goes wrong.

vhf commented 5 years ago

The issue is:

  1. the string gets parsed in local timezone into a DateTime (2018-05-14T00:00:00.000+02:00)
  2. the object is converted to UTC (2018-05-13T22:00:00.000Z)
  3. the object is displayed (it's still in UTC) (2018-05-13)

Solution is either explicitly parsing and displaying in the same TZ or not ever converting to UTC (which means: implicitly parsing and displaying in the same TZ, which defaults to the local one)

ktk commented 5 years ago

Fixed with https://github.com/rdf-ext/rdf-parser-csvw/commit/b6e8bc974da82aef0fae4d78fa4f984de4a3ea30