Skip to content

git log prints UTC wall-clock time next to the author's timezone offset, so the Date line is off by the offset for every non-UTC author #57

Description

@rajpreetcodes

Describe the bug

runGitCli(["log"]) formats commit dates by rendering the timestamp with d.toISOString() (always UTC wall clock) and then appending the ±hhmm offset derived from the author's timezoneOffset. The wall clock is never shifted into that zone, so the printed string denotes an instant that is wrong by exactly the offset.

Location: packages/computer/src/git/cli.ts:828-843 (formatGitTimestamp), reached from formatLogFull (cli.ts:812-826). CommitView.author passes isomorphic-git's timezoneOffset straight through (reads.ts:121).

Commits created inside workerd are UTC (offset 0) and render fine, which is why the suite doesn't catch it. But git log over any cloned repo (the main log use case) shows wrong times for every non-UTC author.

Expected behavior

Real git for the identical commit (GIT_AUTHOR_DATE="1700000000 +0530", git log --date=iso):

Date: 2023-11-15 03:43:20 +0530

i.e. wall clock shifted into the author's zone, then the offset appended.

Steps to reproduce

End-to-end with the package's own plumbing: create an isomorphic-git commit with author: { timestamp: 1_700_000_000, timezoneOffset: -330 } (isomorphic-git uses the Date.getTimezoneOffset() minutes-west convention; -330 is +0530 on the wire, which is what a clone of any IST-authored repo yields), read it back through logWith, render through runGitCli(["log"]). Actual output:

raw author: {"name":"A","email":"a@x","timestamp":1700000000,"timezoneOffset":-330}
stdout: "commit fd95...\nAuthor: A <a@x>\nDate:   2023-11-14 22:13:20 +0530\n..."

2023-11-14 22:13:20 +0530 parses to 2023-11-14T16:43:20Z, which is 5.5 hours before the actual commit instant (2023-11-14T22:13:20Z). The offset sign handling is already correct; only the wall clock is unshifted.

Impact

Anything reading the Date: line (a human, or an agent parsing log output through the shell backend) gets a timestamp wrong by up to ±14 hours for commits authored outside UTC.

Proposed fix

Shift the epoch into the author's zone before formatting: const local = new Date((timestamp + offsetMinutes * 60) * 1000) and format local with the existing toISOString() pipeline, keeping the already-correct ±hhmm suffix. While there, the module's "minutes east of UTC" comments describe the opposite of isomorphic-git's convention (minutes west), which the code's negation already assumes; worth correcting in the same pass.

Environment

  • cloudflare/computer at 76d9e75 (current main), local checkout
  • Comparison output produced with real git on the same machine
  • Node v22.18.0, Windows 11 (platform-independent)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions