Feature Request - Allow lower case am/pm in time
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
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.
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 wraptoLowercase()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.
What is the 4.2 way of doing AM/PM? I'm currently using a variable with nearly the same expression.
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'))
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
I would do toLowerCase(secondsToTimestamp($(internal:time_unix), 'hh:mm a')).
That gives me 08:21 pm (or single h for no leading 0)
I believe that would only give UTC, not adjusted for local time zone 😉
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"
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"
![]()
![]()
![]()
Yes - 12 noon is shown as 0 rather than 12...back to my original I think! :)
