From: Gerd v. Egidy Date: Tue, 31 Aug 2004 10:18:54 +0000 (+0000) Subject: libi2ncommon: (gerd) add seconds_to_hour_minute function (from ui) X-Git-Tag: v2.6~243 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=878698708b70924a541249750993d6b0192e8b57;p=libi2ncommon libi2ncommon: (gerd) add seconds_to_hour_minute function (from ui) --- diff --git a/src/timefunc.cpp b/src/timefunc.cpp index 30c56ac..2dd120d 100644 --- a/src/timefunc.cpp +++ b/src/timefunc.cpp @@ -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(); diff --git a/src/timefunc.hxx b/src/timefunc.hxx index ec08933..b61b233 100644 --- a/src/timefunc.hxx +++ b/src/timefunc.hxx @@ -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 {