Use getTimestamp instead of getCurrentTime in writers.

Setting SOURCE_DATE_EPOCH will allow reproducible builds.

Partially addresses #7093.  This does not suffice to fully enable
reproducible in EPUB, since a unique id is being generated for each
build.
This commit is contained in:
John MacFarlane 2021-02-10 23:13:33 -08:00
parent 3c4a58bad0
commit 390d5e65b2
5 changed files with 7 additions and 7 deletions

View file

@ -28,7 +28,7 @@ import qualified Data.Text as T
import Text.Pandoc.Builder (Blocks, Inlines, fromList, setMeta, trimInlines)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class.PandocMonad (PandocMonad, fetchItem,
readFileFromDirs, getCurrentTime)
readFileFromDirs, getTimestamp)
import Text.Pandoc.CSV (CSVOptions (..), defaultCSVOptions, parseCSV)
import Text.Pandoc.Definition
import Text.Pandoc.Error
@ -685,7 +685,7 @@ directive' = do
"replace" -> B.para <$> -- consumed by substKey
parseInlineFromText (trim top)
"date" -> B.para <$> do -- consumed by substKey
t <- getCurrentTime
t <- getTimestamp
let format = case T.unpack (T.strip top) of
[] -> "%Y-%m-%d"
x -> x

View file

@ -217,7 +217,7 @@ writeDocx opts doc = do
let doc' = Pandoc meta blocks'
username <- P.lookupEnv "USERNAME"
utctime <- P.getCurrentTime
utctime <- P.getTimestamp
oldUserDataDir <- P.getUserDataDir
P.setUserDataDir Nothing
res <- P.readDefaultDataFile "reference.docx"

View file

@ -191,7 +191,7 @@ getEPUBMetadata opts meta = do
let fixDate m =
if null (epubDate m)
then do
currentTime <- lift P.getCurrentTime
currentTime <- lift P.getTimestamp
return $ m{ epubDate = [ Date{
dateText = showDateTimeISO8601 currentTime
, dateEvent = Nothing } ] }
@ -709,7 +709,7 @@ pandocToEPUB version opts doc = do
uuid <- case epubIdentifier metadata of
(x:_) -> return $ identifierText x -- use first identifier as UUID
[] -> throwError $ PandocShouldNeverHappenError "epubIdentifier is null" -- shouldn't happen
currentTime <- lift P.getCurrentTime
currentTime <- lift P.getTimestamp
let contentsData = UTF8.fromStringLazy $ ppTopElement $
unode "package" !
([("version", case version of

View file

@ -68,7 +68,7 @@ pandocToODT :: PandocMonad m
pandocToODT opts doc@(Pandoc meta _) = do
let title = docTitle meta
let authors = docAuthors meta
utctime <- P.getCurrentTime
utctime <- P.getTimestamp
lang <- toLang (getLang opts meta)
refArchive <-
case writerReferenceDoc opts of

View file

@ -312,7 +312,7 @@ presentationToArchive opts pres = do
Nothing -> toArchive . BL.fromStrict <$>
P.readDataFile "reference.pptx"
utctime <- P.getCurrentTime
utctime <- P.getTimestamp
presSize <- case getPresentationSize refArchive distArchive of
Just sz -> return sz