From 16984853e12058bd51b2e5ac065ed84febebc162 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sat, 8 Dec 2018 00:10:16 +0100
Subject: [PATCH] Pretty date printing in PGN

---
 public/javascripts/base_rules.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js
index 71695c49..48a5602c 100644
--- a/public/javascripts/base_rules.js
+++ b/public/javascripts/base_rules.js
@@ -1134,12 +1134,13 @@ class ChessRules
 	// The score is already computed when calling this function
 	getPGN(mycolor, score, fenStart, mode)
 	{
+		const zeroPad = x => { return (x<10 ? "0" : "") + x; };
 		let pgn = "";
 		pgn += '[Site "vchess.club"]<br>';
 		const d = new Date();
 		const opponent = mode=="human" ? "Anonymous" : "Computer";
 		pgn += '[Variant "' + variant + '"]<br>';
-		pgn += '[Date "' + d.getFullYear() + '-' + (d.getMonth()+1) + '-' + d.getDate() + '"]<br>';
+		pgn += '[Date "' + d.getFullYear() + '-' + (d.getMonth()+1) + '-' + zeroPad(d.getDate()) + '"]<br>';
 		pgn += '[White "' + (mycolor=='w'?'Myself':opponent) + '"]<br>';
 		pgn += '[Black "' + (mycolor=='b'?'Myself':opponent) + '"]<br>';
 		pgn += '[FenStart "' + fenStart + '"]<br>';
-- 
2.44.0