{"id":17336239,"url":"https://github.com/alsami/timescaledbtimezonebug","last_synced_at":"2026-02-17T22:02:54.079Z","repository":{"id":78582910,"uuid":"567186452","full_name":"alsami/TimescaleDbTimeZoneBug","owner":"alsami","description":"A reproduction repo for a potential bug with timescale-db and time-zones","archived":false,"fork":false,"pushed_at":"2022-11-17T09:06:55.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T06:37:52.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alsami.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-17T08:58:34.000Z","updated_at":"2022-11-17T08:58:34.000Z","dependencies_parsed_at":"2023-04-21T19:07:49.631Z","dependency_job_id":null,"html_url":"https://github.com/alsami/TimescaleDbTimeZoneBug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alsami/TimescaleDbTimeZoneBug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FTimescaleDbTimeZoneBug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FTimescaleDbTimeZoneBug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FTimescaleDbTimeZoneBug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FTimescaleDbTimeZoneBug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alsami","download_url":"https://codeload.github.com/alsami/TimescaleDbTimeZoneBug/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsami%2FTimescaleDbTimeZoneBug/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29559961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T21:50:49.831Z","status":"ssl_error","status_checked_at":"2026-02-17T21:46:15.313Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T15:28:50.137Z","updated_at":"2026-02-17T22:02:54.062Z","avatar_url":"https://github.com/alsami.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Potential bug with time-zones\n\n## Setup\n\n### Create the database\n\n```sql\nCREATE TABLE IF NOT EXISTS TimeZoneBug (\n    id VARCHAR(100) NOT NULL,\n    timestamp_utc TIMESTAMP NOT NULL,\n    i_value BIGINT,\n    PRIMARY KEY(id, timestamp_utc)\n);\n\nSELECT create_hypertable('TimeZoneBug', 'timestamp_utc', chunk_time_interval =\u003e interval '1 week', if_not_exists =\u003e TRUE);\n\nCREATE INDEX IF NOT EXISTS TimeZoneBug_compound_idx on TimeZoneBug (id, timestamp_utc DESC, i_value);\n```\n\n### Import data\n\nYou can import the data using the `data.csv` file.\n\n## Reproduction\n\nBelow you can see two queries, that are only different in the bucket-size.\nThe datapoint at `2022-11-14 23:00:00.000000 +00:00` within the bucket of `12 hours` will result to `3132`. Whereas the datapoint at `2022-11-14 23:00:00.000000 +00:00` within the bucket of `1 day` will result to `3127`.\n\n```sql\nSELECT\n\tid,\n\ttime_bucket('12 hours', timestamp_utc::timestamptz, 'Europe/Vienna') as time,\n\tmax(i_value) AS i_value\nFROM\n\tpublic.TimeZoneBug\nWHERE\n\ttimestamp_utc BETWEEN '2022-10-17 23:00:00' AND '2022-11-17 23:00:00' AND\n\ti_value IS NOT NULL AND\n\tid IN (\n\t\t'FE:C7:A5:36:EF:E9:AB:36:20480:0'\n)\nGROUP BY\n\tid,\n\ttime\nORDER BY\n\tid,\n\ttime;\n\nSELECT\n\tid,\n\ttime_bucket('1 day', timestamp_utc::timestamptz, 'Europe/Vienna') as time,\n\tmax(i_value) AS i_value\nFROM\n\tpublic.TimeZoneBug\nWHERE\n\ttimestamp_utc BETWEEN '2022-10-17 23:00:00' AND '2022-11-17 23:00:00' AND\n\ti_value IS NOT NULL AND\n\tid IN (\n\t\t'FE:C7:A5:36:EF:E9:AB:36:20480:0'\n)\nGROUP BY\n\tid,\n\ttime\nORDER BY\n\tid,\n\ttime;\n```\n\nWhen using the UTC values, meaning no time-zone provided as part of the query, the data-point at `2022-11-14 12:00:00.000000 +00:00` will be `3120` for within a bucket of `12 hours`. Now given the same query but for a bucket of `1day`, the data-point at `2022-11-14 12:00:00.000000 +00:00` will be also `3120`. \n\n```sql\nSELECT\n\tid,\n\ttime_bucket('12 hours', timestamp_utc::timestamptz) as time,\n\tmax(i_value) AS i_value\nFROM\n\tpublic.TimeZoneBug\nWHERE\n\ttimestamp_utc BETWEEN '2022-10-17 23:00:00' AND '2022-11-17 23:00:00' AND\n\ti_value IS NOT NULL AND\n\tid IN (\n\t\t'FE:C7:A5:36:EF:E9:AB:36:20480:0'\n)\nGROUP BY\n\tid,\n\ttime\nORDER BY\n\tid,\n\ttime;\n\n\nSELECT\n\tid,\n\ttime_bucket('1 day', timestamp_utc::timestamptz) as time,\n\tmax(i_value) AS i_value\nFROM\n\tpublic.TimeZoneBug\nWHERE\n\ttimestamp_utc BETWEEN '2022-10-17 23:00:00' AND '2022-11-17 23:00:00' AND\n\ti_value IS NOT NULL AND\n\tid IN (\n\t\t'FE:C7:A5:36:EF:E9:AB:36:20480:0'\n)\nGROUP BY\n\tid,\n\ttime\nORDER BY\n\tid,\n\ttime;\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsami%2Ftimescaledbtimezonebug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falsami%2Ftimescaledbtimezonebug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsami%2Ftimescaledbtimezonebug/lists"}