diff --git a/CHANGELOG.md b/CHANGELOG.md
index c815247..d6969a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [1.2.2]
+### Fixed
+- Fixed `dc:date` element (publication date) in the generated EPUB
+
## [1.2.1]
### Added
diff --git a/generate.js b/generate.js
index 703a62d..d58e5c1 100644
--- a/generate.js
+++ b/generate.js
@@ -22,8 +22,23 @@ module.exports = (url, epubPath, title, coverURL, language="en-US") => {
epubPath = epubPath ? epubPath : slugify(path.basename(url)) + '.epub';
+ let date = new Date(Date.parse(res.published));
+
+
+ function pad(number) {
+ if (number < 10) {
+ return '0' + number;
+ }
+ return number;
+ }
+
+ // Using toISOString() trips Pandoc, which leaves an empty dc:date element instead.
+ let epubDate = date.getUTCFullYear() +
+ '-' + pad(date.getUTCMonth() + 1) +
+ '-' + pad(date.getUTCDate());
+
let xml = `${title}
-${res.published}
+${epubDate}
${language}
${url}
${url}
diff --git a/package-lock.json b/package-lock.json
index 48ad155..9c9e765 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "url-to-epub",
- "version": "1.2.0",
+ "version": "1.2.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 2013ff5..c6e269e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "url-to-epub",
- "version": "1.2.1",
+ "version": "1.2.2",
"description": "A single tool to generate a standards-compliant EPUB from a webpage. Zero config. Requires pandoc",
"main": "index.js",
"bin": {