]> git.ipfire.org Git - thirdparty/git.git/blame - date.h
documentation: remove extraneous words
[thirdparty/git.git] / date.h
CommitLineData
88c7b4c3
ÆAB
1#ifndef DATE_H
2#define DATE_H
3
2bacb834
ÆAB
4/**
5 * The date mode type. This has DATE_NORMAL at an explicit "= 0" to
6 * accommodate a memset([...], 0, [...]) initialization when "struct
7 * date_mode" is used as an embedded struct member, as in the case of
8 * e.g. "struct pretty_print_context" and "struct rev_info".
9 */
88c7b4c3
ÆAB
10enum date_mode_type {
11 DATE_NORMAL = 0,
12 DATE_HUMAN,
13 DATE_RELATIVE,
14 DATE_SHORT,
15 DATE_ISO8601,
16 DATE_ISO8601_STRICT,
17 DATE_RFC2822,
18 DATE_STRFTIME,
19 DATE_RAW,
20 DATE_UNIX
21};
22
23struct date_mode {
24 enum date_mode_type type;
25 const char *strftime_fmt;
26 int local;
27};
28
f1842898
ÆAB
29#define DATE_MODE_INIT { \
30 .type = DATE_NORMAL, \
31}
32
2bacb834 33/**
88c7b4c3
ÆAB
34 * Convenience helper for passing a constant type, like:
35 *
36 * show_date(t, tz, DATE_MODE(NORMAL));
37 */
38#define DATE_MODE(t) date_mode_from_type(DATE_##t)
39struct date_mode *date_mode_from_type(enum date_mode_type type);
40
2bacb834
ÆAB
41/**
42 * Format <'time', 'timezone'> into static memory according to 'mode'
43 * and return it. The mode is an initialized "struct date_mode"
44 * (usually from the DATE_MODE() macro).
45 */
88c7b4c3 46const char *show_date(timestamp_t time, int timezone, const struct date_mode *mode);
2bacb834
ÆAB
47
48/**
49 * Parse a date format for later use with show_date().
50 *
51 * When the "date_mode_type" is DATE_STRFTIME the "strftime_fmt"
52 * member of "struct date_mode" will be a malloc()'d format string to
974c919d
ÆAB
53 * be used with strbuf_addftime(), in which case you'll need to call
54 * date_mode_release() later.
2bacb834
ÆAB
55 */
56void parse_date_format(const char *format, struct date_mode *mode);
57
974c919d
ÆAB
58/**
59 * Release a "struct date_mode", currently only required if
60 * parse_date_format() has parsed a "DATE_STRFTIME" format.
61 */
62void date_mode_release(struct date_mode *mode);
63
88c7b4c3
ÆAB
64void show_date_relative(timestamp_t time, struct strbuf *timebuf);
65int parse_date(const char *date, struct strbuf *out);
66int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset);
67int parse_expiry_date(const char *date, timestamp_t *timestamp);
68void datestamp(struct strbuf *out);
69#define approxidate(s) approxidate_careful((s), NULL)
70timestamp_t approxidate_careful(const char *, int *);
88c7b4c3
ÆAB
71int date_overflows(timestamp_t date);
72time_t tm_to_time_t(const struct tm *tm);
73#endif