From: Joao <joaopedrobsb3@gmail.com>
Date: Mon, 15 Jan 2024 11:32:59 -0300
Subject: Make the build reproducible

Last-Update: 2024-01-09
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1056398
Forwarded: not-needed

Thanks: Chris Lamb
---
 phd/package-pman.php                          | 2 +-
 phd/phpdotnet/phd/Config.php                  | 2 +-
 phd/phpdotnet/phd/PI/DBHTMLHandler.php        | 4 ++--
 phd/phpdotnet/phd/Package/Generic/TocFeed.php | 2 +-
 phd/phpdotnet/phd/functions.php               | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

--- a/phd/package-pman.php
+++ b/phd/package-pman.php
@@ -27,7 +27,7 @@
 
 $packagexml->setChannel("doc.php.net");
 $packagexml->setAPIVersion("1.0.0");
-$packagexml->setReleaseVersion(date("Y.m.d"));
+$packagexml->setReleaseVersion(date("Y.m.d", getenv('SOURCE_DATE_EPOCH') ?: time()));
 $packagexml->setReleaseStability("stable");
 $packagexml->setAPIStability("stable");
 $packagexml->setLicense("Creative Commons Attribution 3.0", "http://creativecommons.org/licenses/by/3.0/");
--- a/phd/phpdotnet/phd/Config.php
+++ b/phd/phpdotnet/phd/Config.php
@@ -175,7 +175,7 @@
     }
 
     public static function copyright() {
-        return sprintf('Copyright(c) 2007-%s The PHP Documentation Group', date('Y'));
+        return sprintf('Copyright(c) 2007-%s The PHP Documentation Group', date('Y', getenv('SOURCE_DATE_EPOCH') ?: time()));
     }
 
     /**
--- a/phd/phpdotnet/phd/PI/DBHTMLHandler.php
+++ b/phd/phpdotnet/phd/PI/DBHTMLHandler.php
@@ -98,7 +98,7 @@
         }
         $format = $this->getAttribute("format");
         if (!$format) {
-            return $this->format->appendData(date('c'));
+            return $this->format->appendData(date('c', getenv('SOURCE_DATE_EPOCH') ?: time()));
         }
         $dateFormat = "";
         $len = strlen($format);
@@ -107,7 +107,7 @@
                            ? $parseArray[$format[$i]]
                            : $format[$i];
         }
-        return $this->format->appendData(date($dateFormat));
+        return $this->format->appendData(date($dateFormat, getenv('SOURCE_DATE_EPOCH') ?: time()));
     }
 
 }
--- a/phd/phpdotnet/phd/Package/Generic/TocFeed.php
+++ b/phd/phpdotnet/phd/Package/Generic/TocFeed.php
@@ -140,7 +140,7 @@
         $this->setTitle('Index');
         $this->setChunked(true);
         $this->setExt($this->config->ext() === null ? ".atom" : $this->config->ext());
-        $this->date = date('c');
+        $this->date = date('c', getenv('SOURCE_DATE_EPOCH') ?: time());
         if ($this->feedBaseUri === null) {
             $this->feedBaseUri = $this->targetBaseUri;
         }
--- a/phd/phpdotnet/phd/OutputHandler.php
+++ b/phd/phpdotnet/phd/OutputHandler.php
@@ -71,7 +71,7 @@
             return \fprintf($outputStream, "%s\n", $colorMsg);
         }
         
-        $time = \date($this->config->date_format());
+        $time = \date($this->config->date_format(), getenv('SOURCE_DATE_EPOCH') ?: time());
         $timestamp = $this->term_color(\sprintf("[%s - %s]", $time, $infoOrErrorString), $color);
 
         return \fprintf($outputStream, "%s %s\n", $timestamp, $msg);
