Skip to content

Obsidian grid: Export to CSV shifts dates and times by the browser's UTC offset (dates export as the previous day in the Americas) #7143

Open

Description

@bpvan24

Description

When an Obsidian grid is exported to CSV every date and date-time column is shifted by the browser's UTC offset. In any time zone west of UTC (North and South America), a date only value exports as the afternoon or evening of the previous day. Export to Excel from the same grid is correct and the grid on screen is correct.

Reproduced on the demo site with the core Financial Batch List block (/finance/batches) browser time zone America/Los_Angeles:

Batch On screen Export to Excel Export to CSV
#458 6/7/2026 6/7/2026 2026-06-06T17:00:00-07:00
#130 6/6/2026 6/6/2026 2026-06-05T17:00:00-07:00
#457 5/31/2026 5/31/2026 2026-05-30T17:00:00-07:00

Cause. getExportWorkbook() in Rock.JavaScript.Obsidian/Framework/Controls/Grid/grid.partial.obs deliberately rebuilds each RockDateTime as a UTC Date holding the wall clock values, because Excel is not time zone aware:

if (value instanceof RockDateTime) {
    // Excel is not timezone aware, so convert the date into
    // UTC format by stripping off the zone info.
    value = new Date(Date.UTC(value.year, value.month - 1, value.day, value.hour, value.minute, value.second));
}

That is right for workbook.xlsx.writeBuffer(). But downloadWorkbook() writes the CSV from the same workbook with no options:

: await workbook.csv.writeBuffer();

With no dateUTC option exceljs formats Date cells with dayjs(value).format() which is local time. So 6/7/2026 00:00 "UTC" is printed as 2026-06-06T17:00:00-07:00 in Pacific time (-08:00 and 4:00 PM outside daylight saving time). Date-time values shift the same way: 2:30 PM exports as 7:30 AM.

Running the exceljs build that Rock ships (/Obsidian/Libs/exceljs.js) through the same steps outside Rock shows only the browser's time zone matters:

Browser time zone CSV value for 9/28/2026 Excel
America/Los_Angeles 2026-09-27T17:00:00-07:00 9/28/2026
America/New_York 2026-09-27T20:00:00-04:00 9/28/2026
UTC 2026-09-28T00:00:00+00:00 9/28/2026
Asia/Tokyo 2026-09-28T09:00:00+09:00 9/28/2026

This affects every Obsidian grid with a date or date-time column since they all export through getExportWorkbook() / downloadWorkbook(). We first saw it on a Dynamic Data report on our own server (18.7.0), where a purchase date of 9/28/2026 exported as 2026-09-27T17:00:00-07:00.

Screenshot of the grid and the two exported files from the demo site:

Demo site Batches grid (Financial Batch List) showing batch dates 6/7/2026, 6/6/2026 and 5/31/2026 on screen

demo-Batches.csv (Export to CSV, dates shifted)

demo-Batches.xlsx (Export to Excel, dates correct)

Actual Behavior

In Export to CSV date and date-time columns are converted to the browser's local time zone and written as ISO strings with an offset. In the Americas date only values come out as the afternoon or evening of the previous day (for example 6/7/2026 becomes 2026-06-06T17:00:00-07:00) and date-time values are shifted by the same number of hours.

Expected Behavior

CSV export writes the same date and time that the grid shows and that Export to Excel writes regardless of the browser's time zone. For example 6/7/2026 exports as 2026-06-07 or 2026-06-07 00:00:00.

Suggested fix: pass options to the CSV writer in downloadWorkbook() so it formats the already-normalized values in UTC and use a format without an offset since the values are wall clock time not real UTC:

: await workbook.csv.writeBuffer({ dateUTC: true, dateFormat: "YYYY-MM-DD HH:mm:ss" });

With that change the same exceljs build outputs 2026-09-28 00:00:00 in every time zone. (dateUTC: true alone also gives the right date but appends Z which wrongly marks the wall clock value as UTC.)

Steps to Reproduce

  • Use a browser whose time zone is west of UTC (example any US time zone).
  • On the demo site log in as admin and go to Finance > Batches (/finance/batches).
  • Note the Date of the first batch on screen (example 6/7/2026).
  • Open the grid's ⋮ menu and select Export to CSV. Open the file in a text editor: the Date column shows the previous day at 5:00 PM with a -07:00 offset (2026-06-06T17:00:00-07:00).
  • Select Export to Excel from the same menu: the Date column shows 6/7/2026, matching the screen.

Issue Confirmation

  • Perform a search on the Github Issues to see if your bug is already reported.
  • Reproduced the problem on a fresh install or on the demo site.

Rock Version

19.8.1 (demo site) and our production server 18.7.0.

Client Culture Setting

en-US

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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