use SOURCE_DATE_EPOCH for luatex, too
---
 texk/web2c/luatexdir/luatex.c     |   12 ++++++++++--
 texk/web2c/luatexdir/pdf/pdfgen.w |   20 ++++++++++++++++----
 2 files changed, 26 insertions(+), 6 deletions(-)

--- texlive-bin.orig/texk/web2c/luatexdir/luatex.c
+++ texlive-bin/texk/web2c/luatexdir/luatex.c
@@ -858,8 +858,16 @@
 
 void get_date_and_time(int *minutes, int *day, int *month, int *year)
 {
-    time_t myclock = time((time_t *) 0);
-    struct tm *tmptr = localtime(&myclock);
+    char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+    struct tm *tmptr;
+    time_t myclock;
+    if(source_date_epoch) {
+        myclock = strtoull(source_date_epoch, NULL, 10);
+        tmptr = gmtime (&myclock);
+    } else {
+        myclock = time((time_t *) 0);
+        tmptr = localtime(&myclock);
+    }
 
     *minutes = tmptr->tm_hour * 60 + tmptr->tm_min;
     *day = tmptr->tm_mday;
--- texlive-bin.orig/texk/web2c/luatexdir/pdf/pdfgen.w
+++ texlive-bin/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -1534,7 +1534,7 @@
 @c
 #define TIME_STR_SIZE 30 /* minimum size for |time_str| is 24: |"D:YYYYmmddHHMMSS+HH'MM'"| */
 
-static void makepdftime(PDF pdf)
+static void makepdftime(PDF pdf, int utc)
 {
     struct tm lt, gmt;
     size_t size;
@@ -1542,7 +1542,12 @@
     time_t t = pdf->start_time;
     char *time_str = pdf->start_time_str;
     /* get the time */
-    lt = *localtime(&t);
+    if (utc) {
+        lt = *gmtime(&t);
+    }
+    else {
+        lt = *localtime(&t);
+    }
     size = strftime(time_str, TIME_STR_SIZE, "D:%Y%m%d%H%M%S", &lt);
     /* expected format: "YYYYmmddHHMMSS" */
     if (size == 0) {
@@ -1584,10 +1589,17 @@
 @ @c
 void init_start_time(PDF pdf)
 {
+    char *source_date_epoch;
     if (pdf->start_time == 0) {
-        pdf->start_time = time((time_t *) NULL);
         pdf->start_time_str = xtalloc(TIME_STR_SIZE, char);
-        makepdftime(pdf);
+        source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+        if(source_date_epoch) {
+            pdf->start_time = strtoull(source_date_epoch, NULL, 10);
+            makepdftime(pdf,true);
+        } else {
+            pdf->start_time = time((time_t *) NULL);
+            makepdftime(pdf,false);
+        }
     }
 }
 
