Icinga / icingadb-web

Icinga DB Web – UI for Icinga DB – Provides a graphical interface to your Icinga monitoring
GNU General Public License v2.0
68 stars 22 forks source link

Change date display format for relative time/date #1071

Closed alamp1360 closed 1 month ago

alamp1360 commented 1 month ago

Icingaweb currently displays some dates in lists as a relative time, e.g. "1d 5h ago" or "on Sept 25". When, for example, i try to find an alert in the "history" view of a service, that relative time display does not really help in finding an event. Instead, it is additional work to try (and fail) to recalculate the relative dates to an exact date. Of course one could klick on an event to see the exact time, but that requires an extra step.

I guess one of you great developers of icingaweb2 invested a lot of time to realize that feature, but, at least for me it is not very helpful... So i would suggest to implement some sort of "time display format" setting in the personal settings, where users could select either that relative format or an "exact timestamp". My simple solution: Display a combination of the exact date and the relative time. My "fix" would be something like this:

*** DateFormatter.php   2024-08-15 16:43:58.000000000 +0200
--- DateFormatter.php_new       2024-10-03 09:10:29.003981357 +0200
***************
*** 166,179 ****
                  // Move to next case
              case static::DATETIME:
                  $formatted = sprintf(
!                     t('on %s', 'An event happened on the given date or date and time'),
!                     $ago
                  );
                  break;
              case static::RELATIVE:
                  $formatted = sprintf(
!                     t('%s ago', 'An event that happened the given time interval ago'),
!                     $ago
                  );
                  break;
              case static::TIME:
--- 166,181 ----
                  // Move to next case
              case static::DATETIME:
                  $formatted = sprintf(
!                     t('%s (on %s)', 'An event happened on the given date or date and time'),
!                     date('Y-m-d H:i:s', (int) $time),
!                     $ago
                  );
                  break;
              case static::RELATIVE:
                  $formatted = sprintf(
!                     t('%s (%s ago)', 'An event that happened the given time interval ago'),
!                     date('Y-m-d H:i:s', (int) $time),
!                     $ago
                  );
                  break;
              case static::TIME:
alamp1360 commented 1 month ago

Seems this is no issue of icingaweb, but icingaweb-module-icingadb. Sorry for opening the issue here...

lippserd commented 1 month ago

No worries, I will transfer. Since we have a lot of relative timestamps, are you also mainly referring to history views as in https://github.com/Icinga/icingadb-web/issues/1065?

alamp1360 commented 1 month ago

Yes, i am referring to the history view. And it seems i'm not the only one :) However: The display format has changed "recently" from "1day 5 hours ago" to a more readable "on Oct 3 17:10". So it seems the issue was addressed already by some kind soul. From my point of view, with this recent change, the issue is gone.

nilmerg commented 1 month ago

What you've noticed is based on the time difference. If the time difference exceeds a given threshold, the relative format won't be used anymore automatically.

nilmerg commented 1 month ago

Duplicate of #1065