summaryrefslogtreecommitdiff
path: root/cgitcgi/date.h
diff options
context:
space:
mode:
authorkx <kx@radix.pro>2023-03-24 03:51:10 +0300
committerkx <kx@radix.pro>2023-03-24 03:51:10 +0300
commit05d292b208dfe01324826b4c87bbc4da3389a0d5 (patch)
treeb10a2269e9320785f3b61189e75f6778fa167986 /cgitcgi/date.h
parent40ab18a661ff6ada40e73969be293918d346a2f5 (diff)
downloadcgit-ui-05d292b208dfe01324826b4c87bbc4da3389a0d5.tar.xz
Version 0.1.7
Diffstat (limited to 'cgitcgi/date.h')
-rw-r--r--cgitcgi/date.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/cgitcgi/date.h b/cgitcgi/date.h
new file mode 100644
index 0000000..1883ec0
--- /dev/null
+++ b/cgitcgi/date.h
@@ -0,0 +1,49 @@
+
+#ifndef __DATE_H
+#define __DATE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum date_mode_type {
+ DATE_NORMAL = 0,
+ DATE_HUMAN,
+ DATE_RELATIVE,
+ DATE_SHORT,
+ DATE_ISO8601,
+ DATE_ISO8601_STRICT,
+ DATE_RFC2822,
+ DATE_RAW,
+ DATE_UNIX
+};
+
+struct date_mode {
+ enum date_mode_type type;
+ int local;
+};
+
+/*******************************************************
+ Convenience helper for passing a constant type, like:
+
+ show_date( t, tz, DATE_MODE(NORMAL) );
+ */
+#define DATE_MODE(t) date_mode_from_type(DATE_##t)
+struct date_mode *date_mode_from_type(enum date_mode_type type);
+
+
+/*
+ Parse data in the input TEXT, fill struct tm TM and return
+ UTC time_t. On error parse_data returns -1:
+ */
+extern time_t parse_date( struct tm *tm, const char *text );
+
+extern void show_date_relative( struct strbuf *sb, time_t t );
+extern void show_date( struct strbuf *sb, time_t t, int tz, const struct date_mode *mode );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __DATE_H */