jack-ullery / AppAnvil

Graphical user interface for the AppArmor security module (in-progress)
GNU General Public License v3.0
17 stars 12 forks source link

Improve timestamps #60

Closed jack-ullery closed 8 months ago

jack-ullery commented 1 year ago

Is your feature request related to a problem? Please describe. Currently, the timestamps in the Logs tab are displayed in a format similar to ISO 8601: yyyy-MM-dd HH:mm:ss

We put it in this format because it is the easiest to sort. However, I personally find it difficult to read.

Describe the solution you'd like Ideally, the timestamps would be in a localized format, or some other format which is more legible. If we cannot localize timestamps, we might want to continue using a 24 hour clock, because that seems more widespread in most parts of the world.

Regardless of the chosen format, we would want to ensure that the sorting behavior for the column does not change.

Additional context Implementers may have to change the format_timestamp() function in _logadapter.cc, or move it to _status_columnrecord.cc. Additionally, they may consider creating a new ColumnType in _columnheader.h and a custom CellRenderer in _status_columnrecord.cc similar to what we did for the LogEntry type.

54m43lJ commented 9 months ago

Turns out you can simply pass a std::locale object to stream.imbue() to format any string in localized format like this. However, I still find the result less than ideal. For example, weekday is included and in some cases the time zone as well, which makes it very long. Love to hear your thoughts on this. I also have no idea how to unit test this. Maybe implement a locale parameter in the function and test on a specific locale?

jack-ullery commented 8 months ago

Closed with #78

I added the std::locale argument as a parameter to the format_timestamp() function (now located in _status_columnrecord.cc). Which could allow for easier testing, if desired.

But honestly, rigorous testing of that function is not super important.