THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.0KB

  1. #include "cache.h"
  2. #include "tr2_tbuf.h"
  3. void tr2_tbuf_local_time(struct tr2_tbuf *tb)
  4. {
  5. struct timeval tv;
  6. struct tm tm;
  7. time_t secs;
  8. gettimeofday(&tv, NULL);
  9. secs = tv.tv_sec;
  10. localtime_r(&secs, &tm);
  11. xsnprintf(tb->buf, sizeof(tb->buf), "%02d:%02d:%02d.%06ld", tm.tm_hour,
  12. tm.tm_min, tm.tm_sec, (long)tv.tv_usec);
  13. }
  14. void tr2_tbuf_utc_datetime_extended(struct tr2_tbuf *tb)
  15. {
  16. struct timeval tv;
  17. struct tm tm;
  18. time_t secs;
  19. gettimeofday(&tv, NULL);
  20. secs = tv.tv_sec;
  21. gmtime_r(&secs, &tm);
  22. xsnprintf(tb->buf, sizeof(tb->buf),
  23. "%4d-%02d-%02dT%02d:%02d:%02d.%06ldZ", tm.tm_year + 1900,
  24. tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
  25. (long)tv.tv_usec);
  26. }
  27. void tr2_tbuf_utc_datetime(struct tr2_tbuf *tb)
  28. {
  29. struct timeval tv;
  30. struct tm tm;
  31. time_t secs;
  32. gettimeofday(&tv, NULL);
  33. secs = tv.tv_sec;
  34. gmtime_r(&secs, &tm);
  35. xsnprintf(tb->buf, sizeof(tb->buf), "%4d%02d%02dT%02d%02d%02d.%06ldZ",
  36. tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
  37. tm.tm_min, tm.tm_sec, (long)tv.tv_usec);
  38. }