1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 */
|