Description: Honour the SOURCE_DATE_EPOCH environment variable
 If the environment variable SOURCE_DATE_EPOCH is set, uses this date
 instead of current date for generated man pages.
 See https://reproducible-builds.org/specs/source-date-epoch/
Author: Alexis Bienvenüe <pado@passoire.fr>

Index: rdtool-0.6.38/lib/rd/rd2man-lib.rb
===================================================================
--- rdtool-0.6.38.orig/lib/rd/rd2man-lib.rb
+++ rdtool-0.6.38/lib/rd/rd2man-lib.rb
@@ -43,9 +43,14 @@ module RD
       content = content.join
       title = guess_title
       title = title.sub(/\.rd$/i, '').upcase
+      if ENV['SOURCE_DATE_EPOCH'].nil?
+        date=Time.now
+      else
+        date=Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
+      end
       <<"EOT"
 .\\" DO NOT MODIFY THIS FILE! it was generated by rd2
-.TH #{title} 1 "#{Time.now.strftime '%B %Y'}"
+.TH #{title} 1 "#{date.strftime '%B %Y'}"
 #{content}
 EOT
     end # "
