Hi list,

I'm not subscribed to the list, sorry.

I used rclock for reminders a long time ago, and recently
tried it again, but could not get it to work. It is the
parsing of year numbers that is not working when
CENTURY=2000.

Patch attached to make it work with any CENTURY.

/Tommy
I don't understand the logic of the old way, and it's clearly not working unless
CENTURY == 1900.

tm_year is always an offset from 1900, so with CENTURY=2000 the input year 5
should be converted to 105 (1900 + 105 = 2005).

The new logic is:
 1. expect input with century (4 digits), so adjust default (*) from tm_year
 2. if input is without century (2 digits) add the century (CENTURY)
 3. convert back to tm_year format (subtract 1900)
Index: rxvt-unicode-9.30/src/rclock.C
===================================================================
--- rxvt-unicode-9.30.orig/src/rclock.C
+++ rxvt-unicode-9.30/src/rclock.C
@@ -139,7 +139,7 @@
 #define DEFER_TIME     3
 #define ADJUST_TIME
 
-#define CENTURY                2000 /* TODO: verify */
+#define CENTURY                2000
 
 /*----------------------------------------------------------------------*
  * #define FONT_NAME   "7x14"
@@ -1291,13 +1291,13 @@
       dd = GetOneNum (&text, tmval->tm_mday);
       if (*text == '/')
         text++;
-      yy = GetOneNum (&text, tmval->tm_year);
+      yy = GetOneNum (&text, tmval->tm_year + 1900);
 
-      /* handle 20th/21st centuries */
-      if (yy > CENTURY)
-        yy -= 1900;
-      else if (yy < CENTURY)
-        yy += (CENTURY - 1900);
+      /* handle short-hand 2 digit year */
+      if (yy < 100)
+        yy += CENTURY;
+
+      yy -= 1900; /* tm_year format */
 
       while (isspace (*text))
         text++;
_______________________________________________
rxvt-unicode mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/rxvt-unicode

Reply via email to