w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit dbcee390c1c9343869f046cc67c2a7ea2fe457d0
parent f9686b84dc50faf0ba041b957150a92db7267982
Author: ukai <ukai>
Date:   Fri, 27 Dec 2002 15:53:03 +0000

[w3m-dev 03607] mymktime: time zone support
* etc.c (get_zone): added
	(mymktime): parse timezone
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>

Diffstat:
MChangeLog | 6++++++
Metc.c | 42+++++++++++++++++++++++++++++++++++++-----
2 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,5 +1,11 @@ 2002-12-28 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03607] mymktime: time zone support + * etc.c (get_zone): added + (mymktime): parse timezone + +2002-12-28 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03606] Re: clean up displayBuffer() * main.c (followA): B_FORCE_REDRAW (follow_map): ditto diff --git a/etc.c b/etc.c @@ -1646,12 +1646,38 @@ get_time(char **s, int *hour, int *min, int *sec) return 0; } +static int +get_zone(char **s, int *z_hour, int *z_min) +{ + Str tmp = Strnew(); + int zone; + char *ss = *s; + + if (!**s) + return -1; + + if (**s == '+' || **s == '-') + Strcat_char(tmp, *((*s)++)); + while (**s && IS_DIGIT(**s)) + Strcat_char(tmp, *((*s)++)); + if (!(tmp->length == 4 && IS_DIGIT(*ss)) && + !(tmp->length == 5 && (*ss == '+' || *ss == '-'))) { + *s = ss; + return -1; + } + + zone = atoi(tmp->ptr); + *z_hour = zone / 100; + *z_min = zone - (zone / 100) * 100; + return 0; +} + /* RFC 1123 or RFC 850 or ANSI C asctime() format string -> time_t */ time_t mymktime(char *timestr) { char *s; - int day, mon, year, hour, min, sec; + int day, mon, year, hour, min, sec, z_hour = 0, z_min = 0; if (!(timestr && *timestr)) return -1; @@ -1688,8 +1714,12 @@ mymktime(char *timestr) min = 0; sec = 0; } - else if (get_time(&s, &hour, &min, &sec) == -1) { - return -1; + else { + if (get_time(&s, &hour, &min, &sec) == -1) + return -1; + while (*s && !IS_DIGIT(*s) && *s != '+' && *s != '-') + s++; + get_zone(&s, &z_hour, &z_min); } } else { @@ -1715,8 +1745,8 @@ mymktime(char *timestr) return -1; } #ifdef DEBUG - fprintf(stderr, "year=%d month=%d day=%d hour:min:sec=%d:%d:%d\n", - year, mon, day, hour, min, sec); + fprintf(stderr, "year=%d month=%d day=%d hour:min:sec=%d:%d:%d zone=%d:%d\n", + year, mon, day, hour, min, sec, z_hour, z_min); #endif /* DEBUG */ mon -= 3; @@ -1726,6 +1756,8 @@ mymktime(char *timestr) } day += (year - 1968) * 1461 / 4; day += ((((mon * 153) + 2) / 5) - 672); + hour -= z_hour; + min -= z_min; return (time_t) ((day * 60 * 60 * 24) + (hour * 60 * 60) + (min * 60) + sec); }