companion icon indicating copy to clipboard operation
companion copied to clipboard

Feature Request - Allow lower case am/pm in time

Open ChrisSW58 opened this issue 3 weeks ago • 7 comments

Is this a feature relevant to companion itself, and not a specific module?

  • [x] I believe this to be a feature for companion, and is not specific to a module

Is there an existing issue for this?

  • [x] I have searched for similiar existing issues

Describe the feature

In the new 4.2 we have the ability to express time as as am and pm with the text a - AM/PM decorator. It would be good to have an option to show the decorator in lower case - for example A would relate to AM/PM and lowercase a would relate to am/pm. When showing on a button, the lower case - IMHO - looks better.

At the moment I use an expression variable to do this simple task -

concat(($(internal:time_h_12) + 0), ':', ($(internal:time_m)), ($(internal:time_h) >12?' pm':' am'))

The addition of this small feature would remove that expression.

Usecases

No response

ChrisSW58 avatar Dec 10 '25 01:12 ChrisSW58

Just so you're aware, there is already a toLowercase() expression function, so a much simpler expression that would skip the concatenation and ternary function, would be to simply wrap toLowercase() around the time and it'd turn AM to am, or PM to pm.

thedist avatar Dec 10 '25 10:12 thedist

Just so you're aware, there is already a toLowercase() expression function, so a much simpler expression that would skip the concatenation and ternary function, would be to simply wrap toLowercase() around the time and it'd turn AM to am, or PM to pm.

Excellent - many thanks! But it's more complex than that, as the format needs to have second or milliseconds to apply the formatting, and there seems to be an issue with using the Unix millisecond time as it gives the wrong time in the formatting, and also the equation is not being updated ie the time does not change after initialisation, unlike the above equation.

ChrisSW58 avatar Dec 10 '25 13:12 ChrisSW58

What is the 4.2 way of doing AM/PM? I'm currently using a variable with nearly the same expression.

ChadJeffreyAnderson avatar Dec 10 '25 14:12 ChadJeffreyAnderson

What is the 4.2 way of doing AM/PM? I'm currently using a variable with nearly the same expression.

This works - can't get other options to work correctly as stated above - concat(($(internal:time_h_12) + 0), ':', ($(internal:time_m)), ($(internal:time_h) >12?' pm':' am'))

ChrisSW58 avatar Dec 10 '25 14:12 ChrisSW58

I see, thanks. That's basically what I have:

concat(
    $(internal:time_h_12) + 0,  // Trim leading zero
    ":",
    $(internal:time_m),
    (
        $(internal:time_h) > 0 && $(internal:time_h) < 12
    ) ? "am" : "pm"
)

After playing with it for a bit, it looks like toLowerCase( secondsToTimestamp( timestampToSeconds( $(internal:time_hms) ), "h:mm a" ) ) would also get you there, though whether that's simpler is up for debate. I would also prefer a $(internal:time_ampm) kinda thing that just contained either "AM" or "PM" based on system time

ChadJeffreyAnderson avatar Dec 10 '25 16:12 ChadJeffreyAnderson

I would do toLowerCase(secondsToTimestamp($(internal:time_unix), 'hh:mm a')). That gives me 08:21 pm (or single h for no leading 0)

Julusian avatar Dec 10 '25 20:12 Julusian

I believe that would only give UTC, not adjusted for local time zone 😉

ChadJeffreyAnderson avatar Dec 10 '25 21:12 ChadJeffreyAnderson

toLowerCase( secondsToTimestamp( timestampToSeconds( $(internal:time_hms) ), "h:mm a" ) )

Even this has a weird quirk. At noon, it reads "0:00 AM" and one second later, it's "0:00 PM"

Image Image Image Image

ChadJeffreyAnderson avatar Dec 12 '25 21:12 ChadJeffreyAnderson

toLowerCase( secondsToTimestamp( timestampToSeconds( $(internal:time_hms) ), "h:mm a" ) )

Even this has a weird quirk. At noon, it reads "0:00 AM" and one second later, it's "0:00 PM"

Image Image Image Image

Yes - 12 noon is shown as 0 rather than 12...back to my original I think! :)

ChrisSW58 avatar Dec 16 '25 12:12 ChrisSW58