Skip to content
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

time: fix to use format_time #465

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

syusui-s
Copy link

@syusui-s syusui-s commented Nov 13, 2021

Problem

It seems that format_time of tztime doesn't works correctly after v2.14.

If the configuration is written as follows, the string expected to be printed is "<span foreground='#ee9a00'>21-11-14 (Sun) 02:27:51</span>" but I got "%y-%m-%d (%a) %H:%M:%S".

tztime local {
  format = "<span foreground='#ee9a00'>%time</span>"
  format_time = "%y-%m-%d (%a) %H:%M:%S"
}

The detailed behavior of format_time is described in the doc: https://i3wm.org/docs/i3status.html#_tztime

Cause

The cause is that format is not correctly used.
format should be used when printing but format_time is used in v2.14.

The source code of the previous version v2.13 uses format.
https://github.com/i3/i3status/blame/101215bbc83b97de30b6b535bbe2e93d2e913804/src/print_time.c#L68-L77

This pull request fixes it.

Workaround

You can use % in format directly.

tztime local {
  format = "<span foreground='#ee9a00'>%y-%m-%d (%a) %H:%M:%S</span>"
}

Another issue

maybe_escape_markup was used in previous versions to sanitize date-time string formatted with format_time,

https://github.com/i3/i3status/blame/101215bbc83b97de30b6b535bbe2e93d2e913804/src/print_time.c#L74

Although, it doesn't care about the length of the buffer, I think it can lead to buffer overflow.

It seems that maybe_escape_markup is not used in the current implementation.
In other words, the current behavior is the same as if format_time was not used and strftime format was used in format.
I want to keep it as is and I think it is better to be fixed in the another pull request because I think it's rare that the output text is long, so I don't think it's a big problem as it is.

@byly
Copy link

byly commented Sep 14, 2022

This PR's commit fixes the bug for me (when both format_time and format are used in the tztime module).

@fspv fspv mentioned this pull request Mar 18, 2023
@4nd3r 4nd3r mentioned this pull request Aug 21, 2023
iiey added a commit to iiey/dotfiles that referenced this pull request Aug 23, 2024
remove 'format_time'

it's not working since v2.14
i3/i3status#465

description about tztime:
https://i3wm.org/docs/i3status.html#_tztime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants