@@ -207,13 +207,13 @@ void show_date_relative(timestamp_t time, struct strbuf *timebuf)
207
207
(diff + 183 ) / 365 );
208
208
}
209
209
210
- struct date_mode * date_mode_from_type (enum date_mode_type type )
210
+ struct date_mode date_mode_from_type (enum date_mode_type type )
211
211
{
212
- static struct date_mode mode = DATE_MODE_INIT ;
212
+ struct date_mode mode = DATE_MODE_INIT ;
213
213
if (type == DATE_STRFTIME )
214
214
BUG ("cannot create anonymous strftime date_mode struct" );
215
215
mode .type = type ;
216
- return & mode ;
216
+ return mode ;
217
217
}
218
218
219
219
static void show_date_normal (struct strbuf * buf , timestamp_t time , struct tm * tm , int tz , struct tm * human_tm , int human_tz , int local )
@@ -283,21 +283,21 @@ static void show_date_normal(struct strbuf *buf, timestamp_t time, struct tm *tm
283
283
strbuf_addf (buf , " %+05d" , tz );
284
284
}
285
285
286
- const char * show_date (timestamp_t time , int tz , const struct date_mode * mode )
286
+ const char * show_date (timestamp_t time , int tz , struct date_mode mode )
287
287
{
288
288
struct tm * tm ;
289
289
struct tm tmbuf = { 0 };
290
290
struct tm human_tm = { 0 };
291
291
int human_tz = -1 ;
292
292
static struct strbuf timebuf = STRBUF_INIT ;
293
293
294
- if (mode -> type == DATE_UNIX ) {
294
+ if (mode . type == DATE_UNIX ) {
295
295
strbuf_reset (& timebuf );
296
296
strbuf_addf (& timebuf , "%" PRItime , time );
297
297
return timebuf .buf ;
298
298
}
299
299
300
- if (mode -> type == DATE_HUMAN ) {
300
+ if (mode . type == DATE_HUMAN ) {
301
301
struct timeval now ;
302
302
303
303
get_time (& now );
@@ -306,22 +306,22 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
306
306
human_tz = local_time_tzoffset (now .tv_sec , & human_tm );
307
307
}
308
308
309
- if (mode -> local )
309
+ if (mode . local )
310
310
tz = local_tzoffset (time );
311
311
312
- if (mode -> type == DATE_RAW ) {
312
+ if (mode . type == DATE_RAW ) {
313
313
strbuf_reset (& timebuf );
314
314
strbuf_addf (& timebuf , "%" PRItime " %+05d" , time , tz );
315
315
return timebuf .buf ;
316
316
}
317
317
318
- if (mode -> type == DATE_RELATIVE ) {
318
+ if (mode . type == DATE_RELATIVE ) {
319
319
strbuf_reset (& timebuf );
320
320
show_date_relative (time , & timebuf );
321
321
return timebuf .buf ;
322
322
}
323
323
324
- if (mode -> local )
324
+ if (mode . local )
325
325
tm = time_to_tm_local (time , & tmbuf );
326
326
else
327
327
tm = time_to_tm (time , tz , & tmbuf );
@@ -331,17 +331,17 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
331
331
}
332
332
333
333
strbuf_reset (& timebuf );
334
- if (mode -> type == DATE_SHORT )
334
+ if (mode . type == DATE_SHORT )
335
335
strbuf_addf (& timebuf , "%04d-%02d-%02d" , tm -> tm_year + 1900 ,
336
336
tm -> tm_mon + 1 , tm -> tm_mday );
337
- else if (mode -> type == DATE_ISO8601 )
337
+ else if (mode . type == DATE_ISO8601 )
338
338
strbuf_addf (& timebuf , "%04d-%02d-%02d %02d:%02d:%02d %+05d" ,
339
339
tm -> tm_year + 1900 ,
340
340
tm -> tm_mon + 1 ,
341
341
tm -> tm_mday ,
342
342
tm -> tm_hour , tm -> tm_min , tm -> tm_sec ,
343
343
tz );
344
- else if (mode -> type == DATE_ISO8601_STRICT ) {
344
+ else if (mode . type == DATE_ISO8601_STRICT ) {
345
345
strbuf_addf (& timebuf , "%04d-%02d-%02dT%02d:%02d:%02d" ,
346
346
tm -> tm_year + 1900 ,
347
347
tm -> tm_mon + 1 ,
@@ -354,16 +354,16 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
354
354
tz = abs (tz );
355
355
strbuf_addf (& timebuf , "%02d:%02d" , tz / 100 , tz % 100 );
356
356
}
357
- } else if (mode -> type == DATE_RFC2822 )
357
+ } else if (mode . type == DATE_RFC2822 )
358
358
strbuf_addf (& timebuf , "%.3s, %d %.3s %d %02d:%02d:%02d %+05d" ,
359
359
weekday_names [tm -> tm_wday ], tm -> tm_mday ,
360
360
month_names [tm -> tm_mon ], tm -> tm_year + 1900 ,
361
361
tm -> tm_hour , tm -> tm_min , tm -> tm_sec , tz );
362
- else if (mode -> type == DATE_STRFTIME )
363
- strbuf_addftime (& timebuf , mode -> strftime_fmt , tm , tz ,
364
- !mode -> local );
362
+ else if (mode . type == DATE_STRFTIME )
363
+ strbuf_addftime (& timebuf , mode . strftime_fmt , tm , tz ,
364
+ !mode . local );
365
365
else
366
- show_date_normal (& timebuf , time , tm , tz , & human_tm , human_tz , mode -> local );
366
+ show_date_normal (& timebuf , time , tm , tz , & human_tm , human_tz , mode . local );
367
367
return timebuf .buf ;
368
368
}
369
369
0 commit comments