Make my_mktime() public and rename it to tm_to_time_t()
We will use it from the MinGW port's gettimeofday() substitution. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Johannes Sixt committed
Jun 23, 2008 at 08:31 UTC
bb5799d6ef3ad7ee70a138b82e67b93e3aaa8017
2 files changed
+9
-5
date.c
+8
-5
@@ -6,7 +6,10 @@
6
7
#include "cache.h"
8
9
-static time_t my_mktime(struct tm *tm)
9
+/*
10
+ * This is like mktime, but without normalization of tm_wday and tm_yday.
11
+ */
12
+time_t tm_to_time_t(const struct tm *tm)
13
{
14
static const int mdays[] = {
15
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
@@ -67,7 +70,7 @@ static int local_tzoffset(unsigned long time)
70
71
t = time;
72
localtime_r(&t, &tm);
70
- t_local = my_mktime(&tm);
73
+ t_local = tm_to_time_t(&tm);
74
75
if (t_local < t) {
76
eastwest = -1;
@@ -322,7 +325,7 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
325
if (!now_tm)
326
return 1;
327
325
- specified = my_mktime(r);
328
+ specified = tm_to_time_t(r);
329
330
/* Be it commit time or author time, it does not make
331
* sense to specify timestamp way into the future. Make
@@ -572,7 +575,7 @@ int parse_date(const char *date, char *result, int maxlen)
575
}
576
577
/* mktime uses local timezone */
575
- then = my_mktime(&tm);
578
+ then = tm_to_time_t(&tm);
579
if (offset == -1)
580
offset = (then - mktime(&tm)) / 60;
581
@@ -611,7 +614,7 @@ void datestamp(char *buf, int bufsize)
614
615
time(&now);
616
614
- offset = my_mktime(localtime(&now)) - now;
617
+ offset = tm_to_time_t(localtime(&now)) - now;
618
offset /= 60;
619
620
date_string(now, offset, buf, bufsize);
git-compat-util.h
+1
@@ -147,6 +147,7 @@ extern void set_error_routine(void (*routine)(const char *err, va_list params));
147
extern void set_warn_routine(void (*routine)(const char *warn, va_list params));
148
149
extern int prefixcmp(const char *str, const char *prefix);
150
+extern time_t tm_to_time_t(const struct tm *tm);
151
152
#ifdef NO_MMAP
153