From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/Wasabi/bfc/util/timefmt.h | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Src/Wasabi/bfc/util/timefmt.h (limited to 'Src/Wasabi/bfc/util/timefmt.h') diff --git a/Src/Wasabi/bfc/util/timefmt.h b/Src/Wasabi/bfc/util/timefmt.h new file mode 100644 index 00000000..b24e0a99 --- /dev/null +++ b/Src/Wasabi/bfc/util/timefmt.h @@ -0,0 +1,46 @@ +//PORTABLE +#ifndef _TIMEFMT_H +#define _TIMEFMT_H + +/** + Simple time formatting. Can format into a minutes:seconds style + display based on count in seconds only. + + Can also format a timestamp into human readable format. + + @author Nullsoft + @ver 1.0 +*/ +class TimeFmt { +public: + /** + Formats a time value in seconds to minute:seconds. + + If the buffer is too small, the string will be + truncated. + + @param seconds Time value to convert. + @param buf Buffer to receive formatted string. + @param buflen Length of the buffer. + */ + static void printMinSec(int seconds, wchar_t *buf, int buflen); + static void printHourMinSec(int seconds, wchar_t *buf, int buflen, int hoursonlyifneeded=0); + + /** + Formats a time value (from unix timestamp) to + human readable format. + + If the buffer is too small, the string will be + truncated. + + Example of formatted output: + Tue Sep 10 18:34:42 PDT 2002 + + @param buf Buffer to receive the formatted string. + @param bufsize Length of the buffer. + @param ts The timestamp to use. + */ + static void printTimeStamp(wchar_t *buf, int bufsize, int ts); +}; + +#endif -- cgit