add clock times to PGN output default tip

Thu, 16 Apr 2026 19:59:08 +0200

author
Mike Becker <universe@uap-core.de>
date
Thu, 16 Apr 2026 19:59:08 +0200
changeset 101
d4f19182fdc2
parent 100
685af47592b5

add clock times to PGN output

resolves #815

src/chess/pgn.c file | annotate | diff | comparison | revisions
--- a/src/chess/pgn.c	Thu Apr 16 19:49:16 2026 +0200
+++ b/src/chess/pgn.c	Thu Apr 16 19:59:08 2026 +0200
@@ -205,8 +205,15 @@
         } else {
             fprintf(stream, "%s", gamestate->moves[i].string);
         }
-        
-        // TODO: move time and maybe other comments
+
+        /* add clock times when the game was under time control */
+        if (gameinfo->timecontrol) {
+            char clkstr[16];
+            unsigned clkmv = i + 2; /* time for the next move! */
+            uint16_t clk = remaining_movetime2(gameinfo, gamestate, clkmv);
+            print_clk(clk, clkstr, true);
+            fprintf(stream, " {[%%clk %s]}", clkstr);
+        }
         
         /* line break every 10 half-moves */
         if ((i+1) % 10)  {

mercurial