#5089·googletest

[Bug]: JSON output labels local timestamps as UTC

Author: MuszicCreated Sep 8, 2026Updated Sep 8, 2026

Describe the issue

GoogleTest JSON output formats test timestamps using local time, then appends Z. In RFC 3339, Z identifies UTC, so reports generated in any non-UTC timezone contain incorrect instants.

For example, with TZ=Asia/Kolkata, a run at 2026-09-08T12:33:18Z emits:

json
"timestamp": "2026-09-08T18:03:18Z"

The value is 5 hours 30 minutes ahead of the actual UTC time. I expected either a UTC value with Z or a local value with its numeric offset. UTC is the natural fix because the documented JSON representation uses google.protobuf.Timestamp, whose generated form is normalized to UTC.

The cause is FormatEpochTimeInMillisAsRFC3339: it calls PortableLocaltime but unconditionally appends Z.

The existing JSON timestamp test compares the emitted value with datetime.datetime.now(), so it explicitly accepts local time and does not catch the mismatch.

Steps to reproduce the problem

Build the repository tests, then run:

bash
TZ=Asia/Kolkata build/googletest/gtest_no_test_unittest \
  --gtest_output=json:/tmp/gtest-output.json
date -u
cat /tmp/gtest-output.json

The JSON timestamp contains the local wall-clock value but is suffixed with Z.

What version of GoogleTest are you using?

283c17563fe7a1111cd7f581aa5d541e8baeff2f (current main)

What operating system and version are you using?

macOS 26.6.2 (25G83), arm64. The implementation is shared by all platforms.

What compiler and version are you using?

Apple clang 21.0.0 (clang-2100.1.1.101)

What build system are you using?

CMake 4.4.3

Additional context

A fix should introduce a portable UTC conversion (gmtime_s/gmtime_r as appropriate), use it for JSON RFC 3339 timestamps, and update the JSON timestamp regression test to compare against UTC.