mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-27 15:25:54 -04:00
progbase: respect SOURCE_DATE_EPOCH in -write-man option
This commit is contained in:
parent
3e1d98c105
commit
6520b68c2c
@ -201,14 +201,26 @@ write_man_page(std::ostream &out) {
|
||||
// Generate a date string for inclusion into the footer.
|
||||
char date_str[256];
|
||||
date_str[0] = 0;
|
||||
time_t current_time = time(nullptr);
|
||||
time_t current_time;
|
||||
tm *today = nullptr;
|
||||
|
||||
if (current_time != (time_t) -1) {
|
||||
tm *today = localtime(¤t_time);
|
||||
if (today == nullptr || 0 == strftime(date_str, 256, "%d %B %Y", today)) {
|
||||
date_str[0] = 0;
|
||||
// This variable overrides the time we write to the footer.
|
||||
const char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
|
||||
if (source_date_epoch == nullptr || source_date_epoch[0] == 0 ||
|
||||
(current_time = (time_t)strtoll(source_date_epoch, nullptr, 10)) <= 0) {
|
||||
current_time = time(nullptr);
|
||||
if (current_time != (time_t)-1) {
|
||||
today = localtime(¤t_time);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Format as UTC to avoid inconsistency being introduced due to timezones.
|
||||
today = gmtime(¤t_time);
|
||||
}
|
||||
|
||||
if (today == nullptr || 0 == strftime(date_str, 256, "%d %B %Y", today)) {
|
||||
date_str[0] = 0;
|
||||
}
|
||||
|
||||
out << " 1 \"" << date_str << "\" \""
|
||||
<< PandaSystem::get_version_string() << "\" Panda3D\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user