You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I understand correctly the issue here is that date_format behaves differently for POSIXct and hms objects, and for hms objects it shows seconds even when the format requested is only "%H:%M". A more illustrative example is below:
So this is caused because the format.hms method converts hms objects to character, ultimately calling format.Default and ignoring the format argument to date_format (and the underlying methods format.POSIXlt and format.POSIXct)
Assuming we want to fix this in scales without adjusting the format.hms method itself, the simplest way is to call format.Date directly, although I think this is generally considered bad practice. format.Date and strftime (just a wrapper for format.POSIXlt) seem to differ in how the timezone is treated but (with proper consideration of the timezone) either will output the expected result (as shown using strftime in the OP).
This fix of course stops making sense when a user provides an hms object and asks for a format containing dates not just hours minutes and seconds (as is currently the default for date_format). Perhaps it's worth providing hms support in a separate function time_format? Or is it more desirable to generalize date_format with specific handling of hms objects so they print using a format method for date/time objects?