[latex3-commits] [git/LaTeX3-latex3-l3build] standalone: Move epoch normalisation (def5dc4)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Mar 6 08:24:54 CET 2018


Repository : https://github.com/latex3/l3build
On branch  : standalone
Link       : https://github.com/latex3/l3build/commit/def5dc46754adfb33aa780e08537c4fe2ec99754

>---------------------------------------------------------------

commit def5dc46754adfb33aa780e08537c4fe2ec99754
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Mar 6 07:22:07 2018 +0000

    Move epoch normalisation


>---------------------------------------------------------------

def5dc46754adfb33aa780e08537c4fe2ec99754
 l3build-arguments.lua |   21 ---------------------
 l3build-aux.lua       |   16 ++++++++++++++++
 l3build.lua           |   10 ++++++++++
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/l3build-arguments.lua b/l3build-arguments.lua
index b1d5b44..e473d3c 100644
--- a/l3build-arguments.lua
+++ b/l3build-arguments.lua
@@ -263,24 +263,3 @@ if options["engine"] and not options["force"] then
     end
   end
 end
-
--- Tidy up the epoch setting
--- Force an epoch if set at the command line
-if options["epoch"] then
-  epoch           = options["epoch"]
-  forcecheckepoch = true
-  forcedocepoch   = true
-end
--- If given as an ISO date, turn into an epoch number
-do
-  local y, m, d = string.match(epoch, "^(%d%d%d%d)-(%d%d)-(%d%d)$")
-  if y then
-    epoch =
-      os_time({year = y, month = m, day = d, hour = 0, sec = 0, isdst = nil}) -
-      os_time({year = 1970, month = 1, day = 1, hour = 0, sec = 0, isdst = nil})
-  elseif string.match(epoch, "^%d+$") then
-    epoch = tonumber(epoch)
-  else
-    epoch = 0
-  end
-end
diff --git a/l3build-aux.lua b/l3build-aux.lua
index 102f9ba..a0461df 100644
--- a/l3build-aux.lua
+++ b/l3build-aux.lua
@@ -22,10 +22,26 @@ for those people who are interested.
 
 --]]
 
+local match = string.match
+
 --
 -- Auxiliary functions which are used by more than one main function
 --
 
+function normalise_epoch()
+  -- If given as an ISO date, turn into an epoch number
+  local y, m, d = match(epoch, "^(%d%d%d%d)-(%d%d)-(%d%d)$")
+  if y then
+    epoch =
+      os_time({year = y, month = m, day = d, hour = 0, sec = 0, isdst = nil}) -
+      os_time({year = 1970, month = 1, day = 1, hour = 0, sec = 0, isdst = nil})
+  elseif match(epoch, "^%d+$") then
+    epoch = tonumber(epoch)
+  else
+    epoch = 0
+  end
+end
+
 function setepoch()
   return
     os_setenv .. " SOURCE_DATE_EPOCH=" .. epoch
diff --git a/l3build.lua b/l3build.lua
index d688549..8663ec2 100644
--- a/l3build.lua
+++ b/l3build.lua
@@ -87,6 +87,16 @@ if match(arg[0], "l3build(%.lua)$") then
   end
 end
 
+-- Tidy up the epoch setting
+-- Force an epoch if set at the command line
+-- Must be done after loading variables, etc.
+if options["epoch"] then
+  epoch           = options["epoch"]
+  forcecheckepoch = true
+  forcedocepoch   = true
+end
+normalise_epoch()
+
 --
 -- Deal with multiple configs for tests
 --





More information about the latex3-commits mailing list