From 76d3c0d028e738b3c63d4bb1d51a360f54645fee Mon Sep 17 00:00:00 2001
From: John MacFarlane <fiddlosopher@gmail.com>
Date: Fri, 2 Nov 2012 20:14:18 -0700
Subject: [PATCH] Fixed a couple validation bugs that affect epub2 also.

---
 src/Text/Pandoc/Writers/EPUB.hs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 3b4ae8505..70169328e 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -140,7 +140,7 @@ writeEPUB version opts doc@(Pandoc meta _) = do
   let chapToEntry :: Int -> [Tag String] -> Entry
       chapToEntry num ts = mkEntry (showChapter num)
            $ fromStringLazy
-           $ renderTemplate [("body",renderTags ts)]
+           $ renderTemplate [("body",renderTags ts), ("pagetitle",show num)]
            $ pageTemplate
 
   let chapterEntries = zipWith chapToEntry [1..] chunks
@@ -173,8 +173,9 @@ writeEPUB version opts doc@(Pandoc meta _) = do
                     Pandoc meta [Plain t]
   let plainTitle = plainify $ docTitle meta
   let plainAuthors = map plainify $ docAuthors meta
-  let plainDate = maybe "" id $ normalizeDate $ stringify $ docDate meta
   currentTime <- getCurrentTime
+  let plainDate = maybe (showDateTimeISO8601 currentTime) id
+                   $ normalizeDate $ stringify $ docDate meta
   let contentsData = fromStringLazy $ ppTopElement $
         unode "package" ! [("version", case version of
                                              EPUB2 -> "2.0"