p≡p engine FORK
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.

77 lines
1.5 KiB

  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. #pragma once
  4. #include <time.h>
  5. #include "dynamic_api.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. #ifdef WIN32
  10. // this struct is compatible to struct tm
  11. typedef struct _timestamp {
  12. int tm_sec;
  13. int tm_min;
  14. int tm_hour;
  15. int tm_mday;
  16. int tm_mon;
  17. int tm_year;
  18. int tm_wday;
  19. int tm_yday;
  20. int tm_isdst;
  21. long tm_gmtoff; // offset from GMT in seconds
  22. } timestamp;
  23. #else
  24. // for time values all functions are using POSIX struct tm
  25. typedef struct tm timestamp;
  26. #endif
  27. // timegm_with_gmtoff() - convert the broken-out time into time_t, and respect tm_gmtoff
  28. //
  29. // parameters:
  30. // timeptr(in) broken-out time
  31. //
  32. // return value:
  33. // time_t that holds the usual "seconds since epoch"
  34. DYNAMIC_API time_t timegm_with_gmtoff(const timestamp* ts);
  35. // new_timestamp() - allocate a new timestamp
  36. //
  37. // parameters:
  38. // clock (in) initial value or 0 if not available
  39. //
  40. // return value:
  41. // pointer to timestamp object or NULL if out of memory
  42. DYNAMIC_API timestamp * new_timestamp(time_t clock);
  43. // free_timestamp() - free memory occupied by timestamp
  44. //
  45. // parameters:
  46. // ts (in) pointer to timestamp to free
  47. DYNAMIC_API void free_timestamp(timestamp *ts);
  48. // timestamp_dup() - duplicate a timestamp
  49. //
  50. // parameters:
  51. // src (in) pointer to timestamp to duplicate
  52. //
  53. // return value:
  54. // pointer to copy or NULL if out of memory
  55. DYNAMIC_API timestamp * timestamp_dup(const timestamp *src);
  56. #ifdef __cplusplus
  57. }
  58. #endif