#ifndef _SYSTIMETOOLS_H_
#define _SYSTIMETOOLS_H_
#ifndef __USE_XOPEN
#define __USE_XOPEN
#endif
#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif
struct time_ctx {
int fields;
struct tm tm;
int gmtoff;
};
int time_ctx_init(struct time_ctx *ctx);
int time_ctx_set_date(struct time_ctx *ctx, const char *str_date);
int time_ctx_set_hour(struct time_ctx *ctx, const char *str_hour);
int time_ctx_set_time(struct time_ctx *ctx, const char *str_time);
int time_ctx_get_local(struct time_ctx *ctx, uint64_t *epoch_sec,
int32_t *utc_offset_sec);
int time_local_set(uint64_t epoch_sec, int32_t utc_offset_sec);
int time_local_get(uint64_t *epoch_sec, int32_t *utc_offset_sec);
int time_local_ms_get(uint64_t *epoch_sec, uint16_t *ms,
int32_t *utc_offset_sec);
int time_local_to_tm(uint64_t epoch_sec, int32_t utc_offset_sec,
struct tm *tm);
int time_local_from_tm(const struct tm *tm, uint64_t *epoch_sec,
int32_t *utc_offset_sec);
enum time_fmt {
TIME_FMT_SHORT,
TIME_FMT_ISO8601_SHORT = TIME_FMT_SHORT,
TIME_FMT_LONG,
TIME_FMT_ISO8601_LONG = TIME_FMT_LONG,
TIME_FMT_RFC1123,
};
int time_local_format(uint64_t epoch_sec, int32_t utc_offset_sec,
enum time_fmt fmt, char *s, size_t n);
int time_local_parse(const char *s, uint64_t *epoch_sec,
int32_t *utc_offset_sec);
#ifdef __cplusplus
}
#endif
#endif