denodrivers / denodrivers/postgres

The date object is off by one year.

Open
#494 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
655
Forks
97
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The date between January 1 and midnight GMT is different for one year.

Environment is deno v2.1.4, windows 10, postgresql 16.
My time zone is Asia/Tokyo ( GMT+9).
I passed the string 2025-01-01 04:00:00+09:00 to sql, but Thu Jan 01 2026 04:00:00 GMT+0900 comes back.
The moment January 1 is reached by GMT, it will be resolved after 9:00 AM on January 1 in Asia/Tokyo.

```ts
import { Client } from "https://deno.land/x/postgres@v0.19.3/mod.ts";
const client = new Client("postgresql://localhost:5432/postgres");
await client.connect();
await client.queryObject("SET TIME ZONE 'Asia/Tokyo';") // UTC+9
await query(client, `2025-01-01 04:00:00+09:00`);
await query(client, `2025-01-01 05:00:00+09:00`);
await query(client, `2025-01-01 06:00:00+09:00`);
await query(client, `2025-01-01 07:00:00+09:00`);
await query(client, `2025-01-01 08:00:00+09:00`);
await query(client, `2025-01-01 09:00:00+09:00`);
await query(client, `2025-01-01 10:00:00+09:00`);
await query(client, `2025-01-01 11:00:00+09:00`);
async function query(client: Client, timeStr: string) {
await client.queryObject<{ timestamp_value: Date }>(`SELECT '${timeStr}'::timestamptz AS timestamp_value;`).then(r => {
console.log(`${timeStr} -> ${r.rows[0].timestamp_value}`)
});
}
```

output
```plaintext
Visit chrome://inspect to connect to the debugger.
Deno is waiting for debugger to connect.
Debugger session started.
2025-01-01 04:00:00+09:00 -> Thu Jan 01 2026 04:00:00 GMT+0900 (日本標準時) // I am inputting the year 2025, but the output is 2026
2025-01-01 05:00:00+09:00 -> Thu Jan 01 2026 05:00:00 GMT+0900 (日本標準時)
2025-01-01 06:00:00+09:00 -> Thu Jan 01 2026 06:00:00 GMT+0900 (日本標準時)
2025-01-01 07:00:00+09:00 -> Thu Jan 01 2026 07:00:00 GMT+0900 (日本標準時)
2025-01-01 08:00:00+09:00 -> Thu Jan 01 2026 08:00:00 GMT+0900 (日本標準時)
2025-01-01 09:00:00+09:00 -> Wed Jan 01 2025 09:00:00 GMT+0900 (日本標準時)
2025-01-01 10:00:00+09:00 -> Wed Jan 01 2025 10:00:00 GMT+0900 (日本標準時)
2025-01-01 11:00:00+09:00 -> Wed Jan 01 2025 11:00:00 GMT+0900 (日本標準時)
Program finished. Waiting for inspector to disconnect to exit the process...
Debugger session ended
```

**To Reproduce**
As per the above code

**Expected behavior**
To return the correct year in any time zone.

**Screenshots**
![image](https://github.com/user-attachments/assets/c300ce4c-495c-46ff-8e95-47d2e172715f)

**Additional context**

If applicable, add any other context about the problem here.

- deno v2.1.4
- windows10 64bit
- postgresql 16 ( The installation is windows. wsl is not used. )

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.