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

Clock does not recognise fmt-10.0.0 format specifier #2363

Open
bradrn opened this issue Jul 30, 2023 · 10 comments
Open

Clock does not recognise fmt-10.0.0 format specifier #2363

bradrn opened this issue Jul 30, 2023 · 10 comments

Comments

@bradrn
Copy link

bradrn commented Jul 30, 2023

Version 10.0.0 of fmt introduced support for padding seconds, minutes and hours (so e.g. producing output like 1 rather than 01). I have tested that this works on my system by compiling and running the following C++ program:

#include <fmt/chrono.h>

int main() {
    auto t = tm();
    t.tm_year = 2010 - 1900;
    t.tm_mon = 7;
    t.tm_mday = 4;
    t.tm_hour = 1;
    t.tm_min = 15;
    t.tm_sec = 58;
    fmt::print("{:%_I}", t);
    return 0;
}

As expected, this prints 1 (with an initial space).

However, when I try using the same format string with waybar, it simply produces the literal text %_I:

image

My clock configuration is as follows:

    "clock": {
        "tooltip-format": "<tt>{calendar}</tt>",
        "format": "{:%_I}",
        "calendar": {
            "mode": "month",
            "on-scroll": 1,
            "weeks-pos": "left",
            "format": {
                // omitted for brevity
            }
        },
        "actions":  {
                // omitted for brevity
        }
    },

Note that the format string is exactly the same as that used in the C++ program above.

For reference, I am using EndeavourOS (so basically Arch Linux), with waybar-0.9.20-2 and fmt-10.0.0-1. My compositor is Sway, though I presume that makes no difference.

@LukashonakV
Copy link
Contributor

LukashonakV commented Jul 30, 2023

Hi @bradrn , As far as I know, the waybar now doesn't support fmt 10 version. But I might be wrong. Anyway I'll check it, once have a time. My assumption is because arch users recently raised questions about missing fmt 10 library in chain with waybar. See #2353
Thank you.

@bradrn
Copy link
Author

bradrn commented Jul 30, 2023

waybar now doesn't support fmt 10 version

Insofar as I’m aware, it shouldn’t matter, since the call to fmt::print (or whichever function is used by waybar) should be the same either way. It certainly works on my machine with fmt-10.0.0 — it’s just that the new format specifiers introduced by that version don’t seem to work.

@LukashonakV
Copy link
Contributor

waybar now doesn't support fmt 10 version

Insofar as I’m aware, it shouldn’t matter, since the call to fmt::print (or whichever function is used by waybar) should be the same either way. It certainly works on my machine with fmt-10.0.0 — it’s just that the new format specifiers introduced by that version don’t seem to work.

Clock module uses the exact fmt library. So.. it's definitely a strange case when you are able to use fmt10 ... but clock component shows unexpected results.. .OK, let me check...

@bradrn
Copy link
Author

bradrn commented Jul 30, 2023

I probably should have mentioned that other format strings show the expected results, e.g.:

image

This is with {:%a %Od %b,\t%I:%M %p}.

@DigitalDragon64
Copy link

DigitalDragon64 commented Aug 3, 2023

Probably related to this: Since my last system update (waybar and fmt were both updated) the decimal points of the seconds are printed, when just giving the format specifier %S.

Edit: %.0S is not recognized as a format and will be printed as it is.

@ti-mo
Copy link

ti-mo commented Aug 3, 2023

@DigitalDragon64 Same, created an issue for it here: #2378.

@LukashonakV
Copy link
Contributor

LukashonakV commented Aug 4, 2023

Hi @bradrn , I found your conversation fmtlib/fmt#3516
Finally, I built waybar with dependency fmt = 10.0.0. There is an issue: test/chrono-test.cc
format:
EXPECT_EQ(fmt::format("{:%_OI,%_OH,%_OM,%_OS}", tm), " 1, 1, 2, 3");
EXPECT_EQ(fmt::format("{:%-OI,%-OH,%-OM,%-OS}", tm), "1,1,2,3");
doesn't work. At the same time, I see that both merge requets were approved and now are part of the vmt:10 version according to release notes. See fmt 10 RN - row Improved validation of format specifiers for std::chrono::duration (https://github.com/fmtlib/fmt/issues/3219, https://github.com/fmtlib/fmt/pull/3232). Thanks [@ShawnZhong (Shawn Zhong)](https://github.com/ShawnZhong).
There's the same issue, which was waiting for fmt 10 -> #1469
So it actually looks like it needs an issue to be raised to fmt upstream.

I'll do additional investigation. If it won't bring luck, I create an issue to upstream

@bradrn
Copy link
Author

bradrn commented Aug 5, 2023

So it actually looks like it needs an issue to be raised to fmt upstream.

Except that exactly the same format string works when I directly use my version of fmt (see the test program above), but doesn’t work when I use it with waybar. So this can’t be an issue with fmt.

@LukashonakV
Copy link
Contributor

LukashonakV commented Aug 5, 2023

@bradrn, Waybar uses date features like date::zoned_time. According cpp reference now it included into C++20 standard. I've just checked: fmt doesn't work with date::zoned_time. In the same time pure sys_time timpoint works well with fmt.
I'll create an issue to fmt to extend glibc extension on the whole chrono library including TZ API.

Upd: created issue fmtlib/fmt#3572

@bradrn
Copy link
Author

bradrn commented Aug 5, 2023

Ah, that makes sense! Thanks for looking into this @LukashonakV.

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

No branches or pull requests

4 participants