From 878698708b70924a541249750993d6b0192e8b57 Mon Sep 17 00:00:00 2001 From: Gerd v. Egidy Date: Tue, 31 Aug 2004 10:18:54 +0000 Subject: [PATCH] libi2ncommon: (gerd) add seconds_to_hour_minute function (from ui) --- src/timefunc.cpp | 19 +++++++++++++++++++ src/timefunc.hxx | 1 + 2 files changed, 20 insertions(+), 0 deletions(-) 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 { -- 1.7.1