Skip to content

Commit

Permalink
Use source date epoch for draft publication time
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Sep 17, 2024
1 parent dad7637 commit 94db3ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ clean:

## Tests

# Note that SOURCE_DATE_EPOCH=1234567890 corresponds to 1234567890 seconds
# from the unix epoch (January 1, 1970), which is in 2009

# Command used to invoke Inara. Sets an environment variable that makes the
# program ignore the real date.
INARA_TEST_CMD = docker run --rm \
Expand Down
6 changes: 5 additions & 1 deletion data/filters/draft.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
--- resources/default-article-info.yaml
function Meta (meta)
if meta.draft and meta.draft ~= '' then
local epoch = os.getenv 'SOURCE_DATE_EPOCH'
and os.time { year = 1970, month = 1, day = 1, hour = 0, min = 0,
sec = tonumber(os.getenv 'SOURCE_DATE_EPOCH') }
or os.time()
meta.article.doi = '10.xxxxxx/draft'
meta.article.issue = '¿ISSUE?'
meta.article.volume = '¿VOL?'
meta.published = 'unpublished'
meta.published_parts = os.date('*t')
meta.published_parts = os.date('*t', epoch)
return meta
end
end
2 changes: 1 addition & 1 deletion test/expected-draft/paper.tex
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
\renewcommand{\footrulewidth}{0.25pt}

\fancyfoot[L]{\parbox[t]{0.98\headwidth}{\footnotesize{\sffamily Krewinkel
et al. (2024). Article Writing with Markdown and the Open Journals
et al. (2009). Article Writing with Markdown and the Open Journals
publishing pipeline. \emph{Journal of Open Source Software},
\emph{¿VOL?}(¿ISSUE?), ¿PAGE? \url{https://doi.org/10.xxxxxx/draft}}.}}

Expand Down

0 comments on commit 94db3ea

Please sign in to comment.