i3 / i3status

Generates status bar to use with i3bar, dzen2 or xmobar
BSD 3-Clause "New" or "Revised" License
598 stars 251 forks source link

tztime format_time stopped working? #491

Open gsstark opened 2 years ago

gsstark commented 2 years ago

I just recently upgraded from 2.13 to 2.14 and I'm finding that my tztime stanzas that use format %time and format_time have stopped working whereas the stanza that just uses format is still working.

order += "tztime yul"
order += "tztime dub"
order += "tztime ber"
order += "tztime hel"
order += "tztime local"
tztime local {
        format = "%Y-%m-%d %H:%M:%S"
}

tztime yul {
        format = "đŸŽó Łó Ąó ±ó Łó ż%time"
        format_time = "%-H:%M"
    timezone = "America/Montreal"
    hide_if_equals_localtime = true
}
tztime ber {
        format = "đŸ‡©đŸ‡Ș%time"
        format_time = "%-H:%M"
    timezone = "Europe/Berlin"
    hide_if_equals_localtime = true
}
tztime dub {
        format = "🇼đŸ‡Ș%time"
        format_time = "%-H:%M"
    timezone = "Europe/Dublin"
    hide_if_equals_localtime = true
}
tztime hel {
        format = "đŸ‡«đŸ‡ź%time"
        format_time = "%-H:%M"
    timezone = "Europe/Helsinki"
    hide_if_equals_localtime = true
}

Is producing:

🔋99.97% |  | 📡 81% 302 5 Ghz | 🔗1000 Mbit/s |  | DNS ✅✅✅ 20ms |  |  |  |  |  | 0.41 | 🌡52°C | 51.9 GiB |  | %-H:%M | %-H:%M | %-H:%M | 2022-06-29 12:17:30
fspv commented 1 year ago

Same here. Used to work for me, but now it doesn't. Have you managed to find a solution?

fspv commented 1 year ago

Think I got what's the problem. It's been introduced during the refactoring here https://github.com/i3/i3status/commit/7418b5bebbcf40a298c3bd6178ea3917ef065225

In short we should do format_placeholders(format, &placeholders[0], num); instead of format_placeholders(format_time, &placeholders[0], num); because format_time variable contains strftime value, and not the actual format string.

I've created a PR to address this https://github.com/i3/i3status/pull/507

The result of the testing:

Before

build $ ninja && ./i3status
[3/3] Linking target i3status.
{"version":1}                                                                  
[                                                                              
[{"name":"tztime","instance":"UK","markup":"none","full_text":"%Y-%m-%d %I:%M:%S %P %Z"}]
,[{"name":"tztime","instance":"UK","markup":"none","full_text":"%Y-%m-%d %I:%M:%S %P %Z"}]

After

build $ ninja && ./i3status
[3/3] Linking target i3status.
{"version":1}                                                                  
[                                                                              
[{"name":"tztime","instance":"UK","markup":"none","full_text":"<span color='#00FF00'>2022-11-30 08:14:27 pm GMT</span>"}]
,[{"name":"tztime","instance":"UK","markup":"none","full_text":"<span color='#00FF00'>2022-11-30 08:14:28 pm GMT</span>"}]

Sample config

general {
    output_format = "i3bar"
}

order += "tztime UK"

tztime UK {
    format = "<span color='#00FF00'>%time</span>"
    format_time = "%Y-%m-%d %I:%M:%S %P %Z"
    timezone = "Europe/London"
}