Skip to content

date: -u flag ignored in some cases #9018

@yachi

Description

@yachi

Description

The -u flag doesn't work correctly for:

  1. Pure digit strings (e.g., date -u -d "12")
  2. --reference option
  3. --resolution option

Output shows local timezone instead of UTC.

Reproduction

Run in non-UTC timezone:

# Bug #1: Pure digits
$ date -u -d "12" "+%Z"
BST  # Expected: UTC

# Bug #2: --reference
$ touch /tmp/testfile
$ date -u --reference /tmp/testfile "+%Z"
BST  # Expected: UTC

# Bug #3: --resolution
$ date -u --resolution "+%Z"
BST  # Expected: UTC

Cause

src/uu/date/src/date.rs:

  • Line 279: --reference always uses TimeZone::try_system()
  • Line 285: --resolution always uses TimeZone::system()
  • Line 461: parse_date() ignores timezone offset in parsed string

None check the settings.utc flag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions