Skip to content

date input: trailing TZ abbreviation (e.g. 2024-01-01 EST) keeps input TZ on output instead of re-zoning #281

Closed
uutils/coreutils
#12327

Description

@sylvestre

Summary

When -d is given a date string with a trailing timezone abbreviation (e.g. 2024-01-01 EST), GNU date parses the instant and then displays it in the local TZ. uutils parses it correctly but keeps the result in the input's timezone for display, producing the wrong wall-clock time.

Found by a fuzz_date run on uutils/coreutils.

Reproduction

$ TZ=UTC+1 /usr/bin/date -d '2024-01-01 EST'
Mon Jan  1 04:00:00 UTC 2024

$ TZ=UTC+1 target/debug/coreutils date -d '2024-01-01 EST'
Mon Jan  1 00:00:00 -05 2024

$ TZ=UTC+1 /usr/bin/date -d '2024-01-01 EST' '+%H:%M:%S %:z'
04:00:00 -01:00

$ TZ=UTC+1 target/debug/coreutils date -d '2024-01-01 EST' '+%H:%M:%S %:z'
00:00:00 -05:00

Both parsed the instant correctly; the divergence is in how the resulting Zoned is re-projected into the local timezone before display.

Test (in uutils/coreutils integration suite)

#[test]
fn test_date_input_trailing_tz_abbrev_rezones() {
    new_ucmd!()
        .env("LC_ALL", "C")
        .env("TZ", "UTC+1")
        .arg("-d")
        .arg("2024-01-01 EST")
        .arg("+%H:%M:%S %:z")
        .succeeds()
        .stdout_is("04:00:00 -01:00\n");
}

Activity

  1. added
    bug
    good first issue
    on Apr 5, 2026
  2. 0xSoftBoi commented on May 15, 2026

    @0xSoftBoi
    Contributor

    I'd like to take a look at this.

    It looks like the root cause is actually in uutils/coreutils (not parse_datetime): the dedicated abbreviation-aware path try_parse_with_abbreviation in src/uu/date/src/date.rs returns a Zoned in the input's timezone, while the generic parse_datetime fallback already re-zones to the local timezone for display. I'll prepare a fix against uutils/coreutils and link it back here.

  3. 0xSoftBoi commented on May 16, 2026

    @0xSoftBoi
    Contributor

    PR up against uutils/coreutils (fix is on the coreutils side as expected): uutils/coreutils#12327

  4. added a commit that references this issue on May 16, 2026
    dfd6297
  5. added a commit that references this issue on May 28, 2026
    6823708
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

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions