MCPcopy Create free account
hub / github.com/git/git / set_date

Function set_date

date.c:515–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515static int set_date(int year, int month, int day, struct tm *now_tm, time_t now, struct tm *tm)
516{
517 if (month > 0 && month < 13 && day > 0 && day < 32) {
518 struct tm check = *tm;
519 struct tm *r = (now_tm ? &check : tm);
520 time_t specified;
521
522 r->tm_mon = month - 1;
523 r->tm_mday = day;
524 if (year == -1) {
525 if (!now_tm)
526 return 1;
527 r->tm_year = now_tm->tm_year;
528 }
529 else if (year >= 1970 && year < 2100)
530 r->tm_year = year - 1900;
531 else if (year > 70 && year < 100)
532 r->tm_year = year;
533 else if (year < 38)
534 r->tm_year = year + 100;
535 else
536 return -1;
537 if (!now_tm)
538 return 0;
539
540 specified = tm_to_time_t(r);
541
542 /* Be it commit time or author time, it does not make
543 * sense to specify timestamp way into the future. Make
544 * sure it is not later than ten days from now...
545 */
546 if ((specified != -1) && (now + 10*24*3600 < specified))
547 return -1;
548 tm->tm_mon = r->tm_mon;
549 tm->tm_mday = r->tm_mday;
550 if (year != -1)
551 tm->tm_year = r->tm_year;
552 return 0;
553 }
554 return -1;
555}
556
557static int set_time(long hour, long minute, long second, struct tm *tm)
558{

Callers 2

match_multi_numberFunction · 0.85
match_digitFunction · 0.85

Calls 1

tm_to_time_tFunction · 0.85

Tested by

no test coverage detected