sachabruttin / CosmosDbExplorer

A nice client explorer for Azure Cosmos DB
https://www.bruttin.com/CosmosDbExplorer/
MIT License
105 stars 27 forks source link

ISO 8601 date/time string having UTC offset adjusted in value displayed #109

Open aidanwhitehall-dfs opened 6 months ago

aidanwhitehall-dfs commented 6 months ago

Cosmos DB Explorer returns different results when run on a Windows workstation with a clock set to (UTC +00:00) Dublin, Edinburgh, Lisbon, London in the United Kingdom, compared to that returned by running it at cosmos.azure.com on the same workstation.

In Cosmos DB Explorer, the query of some_container which records date/time strings as businessDay:

select c.businessDay,
       c._ts
  from some_container as c
 where endswith(c.businessDay, '+00:00')
   and c._ts = 1621873271
 order by c._ts

returns the result:

[
  {
    "businessDay": "2021-05-24T01:00:00+01:00",
    "_ts": 1621873271
  }
]

whereas it returns this result:

[
    {
        "businessDay": "2021-05-24T00:00:00.0000000+00:00",
        "_ts": 1621873271
    }
]

when run at cosmos.azure.com on the same machine. (The latter is in UTC whereas the former has a UTC offset of +01:00.)

As indicated by the SELECT clause, the the data is stored in UTC, so I'd expect (and prefer) the UTC offset in the result not be shifted by Cosmos DB Explorer.

The date/time value being retrieved as businessDay falls within the date range when Daylight Savings Time was observed by the UK in 2021.

Perhaps Cosmos DB Explorer notes the Region is set to United Kingdom, or that the local clock is showing the time for London, and is adding the UTC offset that would be applied when Daylight Savings was observed (which is +01:00 during that period)?

What do others think? Thanks for you help.

aidanwhitehall-dfs commented 6 months ago

One workaround is to set your workstation's Time zone to UTC and restart Cosmos DB Explorer:

Settings (Win+I) > Time & Language > Time zone: (UTC) Co-ordinated Universal Time
Restart Cosmos DB Explorer

Alternatively, leave the time zone as is, and disable Adjust for daylight saving time automatically.

For the same query as above, the application now returns the response:

[
  {
    "businessDay": "2021-05-24T00:00:00+00:00",
    "_ts": 1621873271
  }
]