[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/devtools/kommander-plugins/datetimefuncs/src
From:       Eric Laffoon <sequitur () kde ! org>
Date:       2009-09-05 22:06:58
Message-ID: 1252188418.051790.1756.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1020265 by sequitur:

added function to format seconds back into time

 M  +24 -0     datetimefuncs.cpp  


--- trunk/playground/devtools/kommander-plugins/datetimefuncs/src/datetimefuncs.cpp \
#1020264:1020265 @@ -59,6 +59,7 @@
   DTF_chronType,
   DTF_fracMin,
   DTF_fracHr,
+  DTF_fmtSec,
   LastFunction
 };
 
@@ -113,6 +114,7 @@
   KommanderPlugin::registerFunction(DTF_chronType, "chronType(QString widget, \
QString date)",  i18n("Test for DateTime, Date or Time and returns the type. If none \
test valid it returns a text error  with your input string declaring it invalid"), \
2);  KommanderPlugin::registerFunction(DTF_fracMin, "fractionalMinutes(QString \
widget, QString Time)",  i18n("Returns the fractional value in minutes of a Time \
string so you can use if for mathematical functions"), 2);  \
KommanderPlugin::registerFunction(DTF_fracHr, "fractionalHours(QString widget, \
QString time)",  i18n("Returns the fractional value in hours of a Time string so you \
can use if for mathematical functions. Handles days+time. ex: <i>2 02:30:00 returns \
50.5</i>"), 2); +  KommanderPlugin::registerFunction(DTF_fmtSec, \
"formatSeconds(QString widget, QString Seconds)",  i18n("Returns a universal time \
formated value from seconds. If total exceeds 23:59:59 it adds a column for days like \
\"11 03:34:15\"."), 2);  /*
   KommanderPlugin::registerFunction(DTF_chronValidate, "chronValidate(QString \
widget, QString date)",  i18n("Checks for a valid DateTime, Date or time. Returns \
                true if any test is passed and false if not."), 2);
 */
@@ -693,6 +695,28 @@
       return s;
       break;
     }
+    case DTF_fmtSec:
+    {
+      int sec = args[0].toInt();
+      int day = sec / 86400;
+      if (day > 0)
+        sec = sec % 86400;
+      int hr = sec / 3600;
+      if (hr > 0)
+        sec = sec % 3600;
+      int min = sec / 60;
+      if (min > 0)
+        sec = sec % 60;
+      QTime t3(hr, min, sec);
+      if (day == 0)
+        return t3.toString();
+      else
+      {
+        QString out = QString::number(day)+" "+t3.toString();
+        return out;
+      }
+      break;
+    }
 /*
     case DTF_dateTimeFormatted:
     {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic