libi2ncommon: (gerd) add seconds_to_hour_minute function (from ui)
authorGerd v. Egidy <gerd.von.egidy@intra2net.com>
Tue, 31 Aug 2004 10:18:54 +0000 (10:18 +0000)
committerGerd v. Egidy <gerd.von.egidy@intra2net.com>
Tue, 31 Aug 2004 10:18:54 +0000 (10:18 +0000)
src/timefunc.cpp
src/timefunc.hxx

index 30c56ac..2dd120d 100644 (file)
@@ -107,6 +107,25 @@ string format_full_time(int seconds)
     return string(buf);
 }
 
+void seconds_to_hour_minute(int seconds, int *hour, int *minute)
+{
+    if (hour != NULL) {
+        *hour = 0;
+        while (seconds >= 3600) {
+            seconds-=3600;
+            (*hour)++;
+        }
+    }
+
+    if (minute != NULL) {
+        *minute = 0;
+        while (seconds >= 60) {
+            seconds-=60;
+            (*minute)++;
+        }
+    }
+}
+
 WEEK::WEEK(const std::string& daystring)
 {
     int len=daystring.length();
index ec08933..b61b233 100644 (file)
@@ -17,6 +17,7 @@ int date_to_seconds(const std::string &date);
 
 std::string make_nice_time(int seconds);
 std::string format_full_time(int seconds);
+void seconds_to_hour_minute(int seconds, int *hour, int *minute);
 
 class WEEK
 {