summaryrefslogtreecommitdiff
path: root/libsowatch/notification.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsowatch/notification.cpp')
-rw-r--r--libsowatch/notification.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/libsowatch/notification.cpp b/libsowatch/notification.cpp
index b4c97b2..e321b58 100644
--- a/libsowatch/notification.cpp
+++ b/libsowatch/notification.cpp
@@ -11,6 +11,25 @@ Notification::~Notification()
{
}
+QString Notification::displayTime() const
+{
+ QDateTime dt = dateTime();
+ int secsDiff = dt.secsTo(QDateTime::currentDateTime());
+ if (secsDiff < 1) {
+ return "";
+ } else if (secsDiff < 60) {
+ return tr("%n second(s) ago", "", secsDiff);
+ } else if (secsDiff < 60*60) {
+ int n = secsDiff / 60;
+ return tr("%n minute(s) ago", "", n);
+ } else if (secsDiff < 60*60*24) {
+ int n = secsDiff / 3600;
+ return tr("%n hour(s) ago", "", n);
+ } else {
+ return dt.toString(Qt::SystemLocaleShortDate);
+ }
+}
+
QImage Notification::image() const
{
return QImage();