Skip to content

Datetime function timezone issue #1096

@LucasBoberg

Description

@LucasBoberg

Bug Report

The datetime() function returns the wrong timezone in node and Chrome but no in Firefox and bun.

Reproduce

Using the following query

RETURN datetime('2023-05-30T01:00:00[America/New_York]')

On Chrome and node I get the following, which is wrong

DateTime {
  year: Integer { low: 2023, high: 0 },
  month: Integer { low: 5, high: 0 },
  day: Integer { low: 30, high: 0 },
  hour: Integer { low: 0, high: 0 },
  minute: Integer { low: 59, high: 0 },
  second: Integer { low: 0, high: 0 },
  nanosecond: Integer { low: 0, high: 0 },
  timeZoneOffsetSeconds: Integer { low: 72000, high: 0 },
  timeZoneId: 'America/New_York'
}

On Firefox and bun I get the following, which is correct

DateTime {
  year: Integer { low: 2023, high: 0 },
  month: Integer { low: 5, high: 0 },
  day: Integer { low: 30, high: 0 },
  hour: Integer { low: 0, high: 0 },
  minute: Integer { low: 59, high: 0 },
  second: Integer { low: 0, high: 0 },
  nanosecond: Integer { low: 0, high: 0 },
  timeZoneOffsetSeconds: Integer { low: -14400, high: -1 },
  timeZoneId: 'America/New_York'
}

The difference is the timeZoneOffsetSeconds which is for some reason different and wrong on Chrome and node

Code for node
const neo4j = require('neo4j-driver')

const driver = neo4j.driver("neo4j://localhost:7687", neo4j.auth.basic("neo4j", "password"))
const session = driver.session()

async function run() {
try {
  const result = await session.run(
    "RETURN datetime('2023-05-30T00:59:00[America/New_York]')"
  )

  const singleRecord = result.records[0]
  const node = singleRecord.get(0)

  console.log(node)
} finally {
  await session.close()
}

// on application exit:
await driver.close()
}
run()
Code for bun
import neo4j from 'neo4j-driver'

const driver = neo4j.driver("neo4j://localhost:7687", neo4j.auth.basic("neo4j", "password"))
const session = driver.session()

async function run() {
try {
  const result = await session.run(
    "RETURN datetime('2023-05-30T00:59:00[America/New_York]')"
  )

  const singleRecord = result.records[0]
  const node = singleRecord.get(0)

  console.log(node)
} finally {
  await session.close()
}

// on application exit:
await driver.close()
}
run()

My Environment

Javascript Runtime Version: node v20.3.0, bun 0.6.9, Firefox 114.0.1, Chrome 114
Driver Version: 5.9.1
Neo4j Version and Edition: Neo4j 5.3.0 enterprise
Operating System: macOS 10.13.4

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions