X-Git-Url: https://git.auder.net/assets/bundles/framework/images/grey_magnifier.png?a=blobdiff_plain;f=public%2Fjavascripts%2Fbase_rules.js;h=48a5602c33c32688762c998d13fd9ab4d54b2261;hb=16984853e12058bd51b2e5ac065ed84febebc162;hp=79301f950833e360d2b1a67995ad636a2a3b9070;hpb=04449c9757e5a39628dcefccdc7be5f95c068fcd;p=vchess.git diff --git a/public/javascripts/base_rules.js b/public/javascripts/base_rules.js index 79301f95..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"]
'; const d = new Date(); const opponent = mode=="human" ? "Anonymous" : "Computer"; pgn += '[Variant "' + variant + '"]
'; - pgn += '[Date "' + d.getFullYear() + '-' + (d.getMonth()+1) + '-' + d.getDate() + '"]
'; + pgn += '[Date "' + d.getFullYear() + '-' + (d.getMonth()+1) + '-' + zeroPad(d.getDate()) + '"]
'; pgn += '[White "' + (mycolor=='w'?'Myself':opponent) + '"]
'; pgn += '[Black "' + (mycolor=='b'?'Myself':opponent) + '"]
'; pgn += '[FenStart "' + fenStart + '"]
'; @@ -1153,7 +1154,7 @@ class ChessRules pgn += ((i/2)+1) + "."; pgn += this.moves[i].notation[0] + " "; } - pgn += score + "

"; + pgn += "

"; // "Complete moves" PGN (helping in ambiguous cases) for (let i=0; i