Skip to content

Commit 2bacb83

Browse files
avargitster
authored andcommitted
date API: add basic API docs
Add basic API doc comments to date.h, and while doing so move the the parse_date_format() function adjacent to show_date(). This way all the "struct date_mode" functions are grouped together. Documenting the rest is one of our #leftoverbits. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f184289 commit 2bacb83

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

date.h

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#ifndef DATE_H
22
#define DATE_H
33

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+
*/
410
enum date_mode_type {
511
DATE_NORMAL = 0,
612
DATE_HUMAN,
@@ -24,15 +30,30 @@ struct date_mode {
2430
.type = DATE_NORMAL, \
2531
}
2632

27-
/*
33+
/**
2834
* Convenience helper for passing a constant type, like:
2935
*
3036
* show_date(t, tz, DATE_MODE(NORMAL));
3137
*/
3238
#define DATE_MODE(t) date_mode_from_type(DATE_##t)
3339
struct date_mode *date_mode_from_type(enum date_mode_type type);
3440

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+
*/
3546
const char *show_date(timestamp_t time, int timezone, const struct date_mode *mode);
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
53+
* be used with strbuf_addftime().
54+
*/
55+
void parse_date_format(const char *format, struct date_mode *mode);
56+
3657
void show_date_relative(timestamp_t time, struct strbuf *timebuf);
3758
int parse_date(const char *date, struct strbuf *out);
3859
int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset);
@@ -41,7 +62,6 @@ void datestamp(struct strbuf *out);
4162
#define approxidate(s) approxidate_careful((s), NULL)
4263
timestamp_t approxidate_careful(const char *, int *);
4364
timestamp_t approxidate_relative(const char *date);
44-
void parse_date_format(const char *format, struct date_mode *mode);
4565
int date_overflows(timestamp_t date);
4666
time_t tm_to_time_t(const struct tm *tm);
4767
#endif

0 commit comments

Comments
 (0)