From: Dirk Eddelbuettel <edd@debian.org>
Date: Oct, 27 2026 08:02:21 -0500
Subject: [PATCH] Use SOURCE_DATE_EPOCH for tradeLog prototype dates

The S4 class definition of 'tradeLog' sets prototype values for its 'date' and
'start.date' slots via Sys.Date().  As setClass() is a top-level call it is
evaluated while the package is installed, baking the wall-clock build date into
the lazyload database files R/quantmod.rdb (and hence .rdx) and preventing a
reproducible build.  Prefer the value of SOURCE_DATE_EPOCH when set (as done
for reproducible builds, see also the r-base patches no-systime-Rd2HTML and
no-systime-sourceEnvironment), falling back to Sys.Date()-equivalent code
otherwise so upstream behaviour is preserved when it is not set.

--- r-cran-quantmod-0.4.29.orig/R/tradeLog.R
+++ r-cran-quantmod-0.4.29/R/tradeLog.R
@@ -15,7 +15,7 @@
                     exch='character'
                     ), 
                     prototype = list(
-                                date=Sys.Date(),
+                                date=as.Date(as.POSIXct(if (nzchar(stamp <- Sys.getenv("SOURCE_DATE_EPOCH"))) as.numeric(stamp) else Sys.time(), origin="1970-01-01", tz="UTC")),
                                 trade.id=0,
                                 action='',
                                 underlying='',
@@ -26,7 +26,7 @@
 				                account.value=10000,
                                 currency='USD',
                                 currency.symbol='$',
-                                start.date=Sys.Date(),
+                                start.date=as.Date(as.POSIXct(if (nzchar(stamp <- Sys.getenv("SOURCE_DATE_EPOCH"))) as.numeric(stamp) else Sys.time(), origin="1970-01-01", tz="UTC")),
                                 exch=''
                     )
         )
