diff --git a/spec/index.html b/spec/index.html
index a1230511..1d8777f4 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -64,7 +64,7 @@
Options
status | Status of specification. Can be `proposal`, `draft`, or `standard`. Default is `proposal`. |
stage | Stage of proposal. Must be a number if provided, but is optional. Sets `version` to `Stage N Draft`, but can be overridden. |
version | Version of specification, for example `6<sup>th</sup> Edition` or `Draft 1`. Optional. |
- date | Date the spec was generated. Used for various pieces of boilerplate that include dates. Defaults to today's date. |
+ date | Date the spec was generated. Used for various pieces of boilerplate that include dates. Defaults to the value of the SOURCE_DATE_EPOCH environment variable (as a number of second since the Unix epoch) if it exists, otherwise defaults to today's date. |
shortname | Shortname of specification, for example `ECMA-262` or `ECMA-402`. |
location | URL of this specification. Use in conjunction with the biblio file to enable external specs to reference this one. |
copyright | Emit copyright and software license information. Boolean, default true. |
diff --git a/src/cli.ts b/src/cli.ts
index 89ba0f43..503b2aa6 100644
--- a/src/cli.ts
+++ b/src/cli.ts
@@ -150,6 +150,15 @@ const build = debounce(async function build() {
warnings.push(err);
};
+ if (process.env.SOURCE_DATE_EPOCH) {
+ const sde = process.env.SOURCE_DATE_EPOCH.trim();
+ if (!/^[0-9]+/.test(sde)) {
+ fail(`SOURCE_DATE_EPOCH value ${sde} is not valid`);
+ }
+ const ts = +sde;
+ opts.date = new Date(ts * 1000);
+ }
+
const spec = await ecmarkup.build(args.files[0], utils.readFile, opts);
if (args.verbose) {