fix year handling - ics2txt - convert icalendar .ics file to plain text
 (HTM) git clone git://bitreich.org/ics2txt git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ics2txt
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
       ---
 (DIR) commit cf0323aa059bf54b2a88046d7e6e17efe16f9a2e
 (DIR) parent b422b3d0c401d13978ded1934e6ac743ee8a12d9
 (HTM) Author: Josuah Demangeon <me@josuah.net>
       Date:   Mon, 14 Jun 2021 00:41:39 +0200
       
       fix year handling
       
       It looks like it made a long time I did not use <time.h>.
       
       Diffstat:
         M ical.c                              |      14 ++++++++------
       
       1 file changed, 8 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/ical.c b/ical.c
       @@ -50,13 +50,15 @@ ical_get_time(IcalParser *p, char *s, time_t *t)
                    (p->current && p->current->tzid[0] != '\0') ? p->current->tzid :
                    "";
        
       +#define N(i, x) ((s[i] - '0') * x)
       +
                /* date */
                for (int i = 0; i < 8; i++)
                        if (!isdigit(s[i]))
                                return ical_error(p, "invalid date format");
       -        tm.tm_year = s[0] * 1000 + s[1] * 100 + s[2] * 10 + s[3];
       -        tm.tm_mon = s[4] * 10 + s[5] - 1;
       -        tm.tm_mday = s[6] * 10 + s[7];
       +        tm.tm_year = N(0,1000) + N(1,100) + N(2,10) + N(3,1) - 1900;
       +        tm.tm_mon = N(4,10) + N(5,1) - 1;
       +        tm.tm_mday = N(6,10) + N(7,1);
                s += 8;
        
                if (*s == 'T') {
       @@ -65,9 +67,9 @@ ical_get_time(IcalParser *p, char *s, time_t *t)
                        for (int i = 0; i < 6; i++)
                                if (!isdigit(s[i]))
                                        return ical_error(p, "invalid time format");
       -                tm.tm_hour = s[0] * 10 + s[1];
       -                tm.tm_min = s[2] * 10 + s[3];
       -                tm.tm_sec = s[4] * 10 + s[5];
       +                tm.tm_hour = N(0,10) + N(1,1);
       +                tm.tm_min = N(2,10) + N(3,1);
       +                tm.tm_sec = N(4,10) + N(5,1);
                        if (s[6] == 'Z')
                                tzid = "UTC";
                }