Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rel implicitly converted to UTC #19

Open
sjlongland opened this issue Apr 28, 2020 · 0 comments
Open

Rel implicitly converted to UTC #19

sjlongland opened this issue Apr 28, 2020 · 0 comments

Comments

@sjlongland
Copy link
Contributor

I noticed this taking a JSON grid from the WideSky API server system tests, loading it in and dumping it out in ZINC format for documentation purposes…

if I create a file grid.json:

{
  "meta": {
    "ver": "2.0",
    "hisEnd": "t:2016-01-01T00:00:00-00:00 Rel",
    "hisStart": "t:2016-01-01T00:00:00-00:00 Rel"
  },
  "cols": [
    {
      "name": "ts"
    },
    {
      "name": "v0",
      "id": "r:00000111-0000-0000-0000-000000000000"
    },
    {
      "name": "v1",
      "id": "r:00000112-0000-0000-0000-000000000000"
    }
  ],
  "rows": [
    {
      "ts": "t:2016-01-01T00:00:00-00:00 Rel",
      "v0": "n:1 Wh",
      "v1": "n:1 Wh"
    }
  ]
}

then in a Python shell:

import hszinc

grid = hszinc.parse(open('grid.json','r').read(), mode=hszinc.MODE_JSON)
open('grid.zinc','w').write(hszinc.dump(grid, mode=HSZINC.MODE_ZINC))

I get this output:

ver:"2.0" hisEnd:2016-01-01T00:00:00+00:00 UTC hisStart:2016-01-01T00:00:00+00:00 UTC
ts,v0 id:@00000111-0000-0000-0000-000000000000,v1 id:@00000112-0000-0000-0000-000000000000
2016-01-01T00:00:00+00:00 UTC,1.0Wh,1.0Wh

Those DateTime literals should remain in the Rel time-zone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant