subsurface/core/subsurface-time.h
Berthold Stoeger 2e1d852e36 core: convert filter_constraint_data_to_string to C++
Return an std::string to avoid memory management headaches.

While doing that, convert time.c to C++ so that
format_datetime directly returns an std::string.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2024-03-10 11:01:42 +13:00

30 lines
674 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(const 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 const char *monthname(int mon);
#ifdef __cplusplus
}
#include <string>
std::string format_datetime(timestamp_t timestamp); /* ownership of string passed to caller */
#endif
#endif