Skip to content

fix: set the cover page date to pdf build date#9

Open
foodelevator wants to merge 1 commit intomasterfrom
coverpage-date
Open

fix: set the cover page date to pdf build date#9
foodelevator wants to merge 1 commit intomasterfrom
coverpage-date

Conversation

@foodelevator
Copy link
Member

Not sure exactly what is best to set the date to, but went with current date when building (which happens when pushing/merging to master and that's what's uploaded to the link we have posted in Discord).

My first idea was to get the date of the latest commit, but that requires traversing .git/HEAD -> .git/refs/heads/$branch_name -> .git/objects/${commit_id::2}/${commit_id:2}, then zlib-decompressing that, extracting the date on a line like committer $name <$email> $date $tz_offset then interpreting a unix timestamp. Or of course using git log -1 --format=%cd, but you can't run external commands from typst so that would need to be put in a file before compiling so we would need to add a build script. But maybe that would be fine/better?

Also, you can't get Swedish month names i typst by default, so I had to insert them manually.

@foodelevator foodelevator requested a review from RafDevX April 3, 2025 11:30
@RafDevX
Copy link
Member

RafDevX commented Apr 3, 2025

If you want to force Typst to follow a specific date, just setting SOURCE_DATE_EPOCH should be sufficient (but yes we'd still need some sort of build script probably; or maybe it's achievable through direnv?)

See typst/typst#5282

@foodelevator
Copy link
Member Author

Ah, so something like SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) typst compile stadgar.typ would probably work then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants