mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
This is a user request: add local time of dive to the tooltip. Showing a localized time was surprisingly complex. First I had to add a function that decomposes a timestamp into h/m/s. Then the QLocale time-string has to be stripped of the timezone. Fixes #3469. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
32 lines
760 B
C
32 lines
760 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
|
|
|
|
struct time_of_day {
|
|
int h, m, s;
|
|
};
|
|
|
|
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);
|
|
extern struct time_of_day utc_time_of_day(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 */
|
|
|
|
extern const char *monthname(int mon);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|