PRItime: introduce a new "printf format" for timestamps
Currently, Git's source code treats all timestamps as if they were unsigned longs. Therefore, it is okay to write "%lu" when printing them. There is a substantial problem with that, though: at least on Windows, time_t is *larger* than unsigned long, and hence we will want to switch away from the ill-specified `unsigned long` data type. So let's introduce the pseudo format "PRItime" (currently simply being defined to "lu") to make it easier to change the data type used for timestamps. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
1aeb7e756c
commit
cb71f8bdb5
@ -53,7 +53,7 @@ static void parse_dates(const char **argv, struct timeval *now)
|
||||
|
||||
strbuf_reset(&result);
|
||||
parse_date(*argv, &result);
|
||||
if (sscanf(result.buf, "%lu %d", &t, &tz) == 2)
|
||||
if (sscanf(result.buf, "%"PRItime" %d", &t, &tz) == 2)
|
||||
printf("%s -> %s\n",
|
||||
*argv, show_date(t, tz, DATE_MODE(ISO8601)));
|
||||
else
|
||||
|
Reference in New Issue
Block a user