subsurface/core/subsurface-time.h
Berthold Stoeger 8f898477cb core: add helper functions to format / parse timestamps
To save datetime-based filter constraints to git or XML,
it is preferrable to use human-readable representations.
Therefore, add helper functions to format / parse timestamp_t
64-bit values in the "YYYY-MM-DD hh:mm:ss" format.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-09-29 16:13:03 -07:00

25 lines
609 B
C

// SPDX-License-Identifier: GPL-2.0
#ifndef TIME_H
#define TIME_H
#include "units.h"
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
extern timestamp_t utc_mktime(struct tm *tm);
extern void utc_mkdate(timestamp_t, struct tm *tm);
extern int utc_year(timestamp_t timestamp);
extern int utc_weekday(timestamp_t timestamp);
/* parse and format date times of the form YYYY-MM-DD hh:mm:ss */
extern timestamp_t parse_datetime(const char *s); /* returns 0 on error */
extern char *format_datetime(timestamp_t timestamp); /* ownership of string passed to caller */
#ifdef __cplusplus
}
#endif
#endif