Skip to content

Display timestamps in local time zone, respecting TZ environment variable #2200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
realsobek opened this issue Apr 16, 2025 · 4 comments
Open
Labels
downstream Also reported in Jira or Bugzilla Priority: LOW RFE Request For Enhancement (as opposed to a bug) Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take

Comments

@realsobek
Copy link
Contributor

dnf-4.23.0-1.fc40.noarch uses local time timestamps (at the moment +0200 due to summer time) in dnf history and /var/log/dnf.log.
dnf5-5.2.12.0-2.fc42.x86_64 uses UTC time timestamps in dnf history and /var/log/dnf5.log. In example below you see the 2 hour difference. The difference makes it harder to trace actions, because all other apps' logs and timestamps use local time.
Because RPM scriptlet action's output gets truncated I grep /var/log/dnf.log after automated system installation is done.

I cannot find an option to force dnf5 to use local time. Is there no such option? Something like dnf history list --uselocaltime would be handy.

I found an issue was created for upstream tests #900 reply:

It's normal that time formatting functions and thus applications honor a localtime zone.

In rpm-software-management/ci-dnf-stack#1386 the same issue got reply:

This got changed in #844 when the Issued time was unified with the rest of dates printed by dnf5 (like in repo info or history list). The times are now always in UTC.

I do not know the big picture: brainstorming: Add dnf5 option to force UTC time output? Update the upstream tests to cope with local time?
If no change is intended, please, add a note to https://dnf5.readthedocs.io/en/stable/changes_from_dnf4.7.html that dnf5 output is unified on UTC.

Example with Fedora 42 and dnf5:

# timedatectl
               Local time: Wed 2025-04-16 13:40:20 CEST
           Universal time: Wed 2025-04-16 11:40:20 UTC
                 RTC time: Wed 2025-04-16 11:40:20
                Time zone: Europe/Berlin (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no
# date
Wed Apr 16 01:40:18 PM CEST 2025
# dnf install -y leafpad
...
# dnf history list
 ID Command line                        Date and time       Action(s) Altered
255 dnf install -y leafpad              2025-04-16 11:40:28                 1
...
# vim /var/log/dnf5.log
...
2025-04-16T11:40:25+0000 [8393] INFO --- DNF5 launched with arguments: "dnf install -y leafpad" ---
...

Kudos for the timestamp formatting:
2025-04-16T11:40:25
I like it much better than journalctl's output:
Apr 16 13:40:50

@ppisar
Copy link
Contributor

ppisar commented Apr 16, 2025

In my opinion, dnf5 should print all times in the local time zone. I.e. your option would be TZ variable.

I believe that the referred change was just a quick fix to get all time stamps alike.

I will bring this topic to DNF team meating.

@realsobek
Copy link
Contributor Author

Thank you. Take your time.

At the moment the TZ variable is not honored by dnf5 on Fedora 42 (other apps, like date do; I use bash shell), i.e. both commands print UTC timestamp:

# TZ='Asia/Kolkata' dnf history list --contains-pkgs leafpad | head -2
# export TZ='Europe/Berlin' ; dnf history list --contains-pkgs leafpad | head -2

@ppisar
Copy link
Contributor

ppisar commented Apr 17, 2025

DNF team discussed this issue and concluded that:

  • Time stamps displayed in the user interface should be in local time zone.
  • Time stamps written in logs should be in UTC.

All time stamps should be formatted with a time offset indicator, UTC offset abbreviated as "Z".

@ppisar ppisar changed the title option to use local time timestamps Display timestamps in local time zone, respecting TZ environment variable Apr 17, 2025
@ppisar ppisar added RFE Request For Enhancement (as opposed to a bug) Priority: LOW Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take labels Apr 17, 2025
@ppisar
Copy link
Contributor

ppisar commented Apr 28, 2025

Fedora bug report: https://bugzilla.redhat.com/show_bug.cgi?id=2316624

@ppisar ppisar added the downstream Also reported in Jira or Bugzilla label Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
downstream Also reported in Jira or Bugzilla Priority: LOW RFE Request For Enhancement (as opposed to a bug) Triaged Someone on the DNF 5 team has read the issue and determined the next steps to take
Projects
None yet
Development

No branches or pull requests

2 participants