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".
24 enum date_mode_type type
;
25 const char *strftime_fmt
;
29 #define DATE_MODE_INIT { \
30 .type = DATE_NORMAL, \
34 * Convenience helper for passing a constant type, like:
36 * show_date(t, tz, DATE_MODE(NORMAL));
38 #define DATE_MODE(t) date_mode_from_type(DATE_##t)
39 struct date_mode
*date_mode_from_type(enum date_mode_type type
);
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).
46 const char *show_date(timestamp_t time
, int timezone
, const struct date_mode
*mode
);
49 * Parse a date format for later use with show_date().
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
53 * be used with strbuf_addftime(), in which case you'll need to call
54 * date_mode_release() later.
56 void parse_date_format(const char *format
, struct date_mode
*mode
);
59 * Release a "struct date_mode", currently only required if
60 * parse_date_format() has parsed a "DATE_STRFTIME" format.
62 void date_mode_release(struct date_mode
*mode
);
64 void show_date_relative(timestamp_t time
, struct strbuf
*timebuf
);
65 int parse_date(const char *date
, struct strbuf
*out
);
66 int parse_date_basic(const char *date
, timestamp_t
*timestamp
, int *offset
);
67 int parse_expiry_date(const char *date
, timestamp_t
*timestamp
);
68 void datestamp(struct strbuf
*out
);
69 #define approxidate(s) approxidate_careful((s), NULL)
70 timestamp_t
approxidate_careful(const char *, int *);
71 timestamp_t
approxidate_relative(const char *date
);
72 int date_overflows(timestamp_t date
);
73 time_t tm_to_time_t(const struct tm
*tm
);