From 5335c0c3d32b52f067af39f1e69d1e3b02841068 Mon Sep 17 00:00:00 2001
From: Bruce Cowan <bruce@bcowan.me.uk>
Date: Fri, 18 May 2018 10:38:43 +0100
Subject: [PATCH] Better copyright year detection

---
 src/find_year.sh | 3 +++
 src/main.c       | 6 ++----
 src/meson.build  | 3 +++
 3 files changed, 8 insertions(+), 4 deletions(-)
 create mode 100755 src/find_year.sh

diff --git a/src/find_year.sh b/src/find_year.sh
new file mode 100755
index 0000000..507cea2
--- /dev/null
+++ b/src/find_year.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/sh
+
+stat -c '%y' `find . -type f | xargs` | sort -r | head -n1 | cut -d "-" -f1 | tr -d '\n'
diff --git a/src/main.c b/src/main.c
index 278b4c3..f1e60a7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -20,6 +20,7 @@
 
 #include <gtk/gtk.h>
 
+#include "config.h"
 #include "rugby-app-window.h"
 
 static void
@@ -39,10 +40,7 @@ about_activated (GSimpleAction *simple,
     GtkWindow *window = gtk_application_get_active_window (app);
 
     const gchar *authors[] = { "Bruce Cowan", NULL };
-    g_autoptr (GDateTime) date = g_date_time_new_now_local ();
-    gint year = g_date_time_get_year (date);
-    g_autofree gchar *copyright = g_strdup_printf ("Copyright © 2012–%d Bruce Cowan",
-                                                   year);
+    const gchar *copyright = "Copyright © 2012–" COPYRIGHT_YEAR " Bruce Cowan";
 
     gtk_show_about_dialog (window,
                            "logo-icon-name", "face-wink",
diff --git a/src/meson.build b/src/meson.build
index fbe94bb..bfb2b6f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -5,6 +5,9 @@ conf.set('TRY_POINTS', get_option('try_points'))
 conf.set('UTRY_POINTS', get_option('utry_points'))
 conf.set('KICK_POINTS', get_option('kick_points'))
 
+year = run_command('find_year.sh').stdout()
+conf.set_quoted('COPYRIGHT_YEAR', year)
+
 config_h = configure_file(configuration: conf, output: 'config.h')
 
 sources = files(
-- 
GitLab