Skip to content
New issue

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

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

Already on GitHub? # to your account

tztime format_time stopped working? #491

Open
gsstark opened this issue Jun 29, 2022 · 2 comments
Open

tztime format_time stopped working? #491

gsstark opened this issue Jun 29, 2022 · 2 comments

Comments

@gsstark
Copy link

gsstark commented Jun 29, 2022

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
Copy link

fspv commented Nov 30, 2022

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

@fspv
Copy link

fspv commented Nov 30, 2022

Think I got what's the problem. It's been introduced during the refactoring here 7418b5b

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 #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"
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants