Skip to content

Commit

Permalink
Supporting SOURCE_DATE_EPOCH environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
martinSusz authored Dec 1, 2022
1 parent 8aaf80c commit 21cebf4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,17 @@ static inline rk_time getTime(bool reproducible) {
rkTime.second = 00;
} else {
struct tm *tm;
time_t tt = time(NULL);
time_t tt;
time_t now;
char *source_date_epoch;
/* This assumes that the SOURCE_DATE_EPOCH environment variable will contain
a correct, positive integer in the time_t range */
if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL ||
(now = (time_t)strtoll(source_date_epoch, NULL, 10)) <= 0)
tt = time(&now);
else
tt = time(NULL);

tm = localtime(&tt);
rkTime.year = tm->tm_year + 1900;
rkTime.month = tm->tm_mon + 1;
Expand Down

0 comments on commit 21cebf4

Please sign in to comment.