timefmt.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //PORTABLE
  2. #ifndef _TIMEFMT_H
  3. #define _TIMEFMT_H
  4. /**
  5. Simple time formatting. Can format into a minutes:seconds style
  6. display based on count in seconds only.
  7. Can also format a timestamp into human readable format.
  8. @author Nullsoft
  9. @ver 1.0
  10. */
  11. class TimeFmt {
  12. public:
  13. /**
  14. Formats a time value in seconds to minute:seconds.
  15. If the buffer is too small, the string will be
  16. truncated.
  17. @param seconds Time value to convert.
  18. @param buf Buffer to receive formatted string.
  19. @param buflen Length of the buffer.
  20. */
  21. static void printMinSec(int seconds, wchar_t *buf, int buflen);
  22. static void printHourMinSec(int seconds, wchar_t *buf, int buflen, int hoursonlyifneeded=0);
  23. /**
  24. Formats a time value (from unix timestamp) to
  25. human readable format.
  26. If the buffer is too small, the string will be
  27. truncated.
  28. Example of formatted output:
  29. Tue Sep 10 18:34:42 PDT 2002
  30. @param buf Buffer to receive the formatted string.
  31. @param bufsize Length of the buffer.
  32. @param ts The timestamp to use.
  33. */
  34. static void printTimeStamp(wchar_t *buf, int bufsize, int ts);
  35. };
  36. #endif