*** ../../xplot/timeval.c Fri Jul 5 16:04:52 2002 --- timeval.c Wed Apr 24 18:11:34 2002 *************** *** 28,53 **** NOT be used in advertising or publicity pertaining to distribution of the software. Title to copyright in this software and any associated documentation shall at all times remain with M.I.T., and USER agrees to preserve same. */ #include #include #include #include #include "xplot.h" ! ! extern time_t timezone; ! #ifdef HAS_ALTZONE ! extern time_t altzone; ! #else ! #define altzone (timezone - 3600) ! #endif ! ! extern int daylight; ! extern char *tzname[2]; ! inline static void timeval_fix(coord *r) { --- 28,44 ---- NOT be used in advertising or publicity pertaining to distribution of the software. Title to copyright in this software and any associated documentation shall at all times remain with M.I.T., and USER agrees to preserve same. */ + #include #include #include #include #include #include "xplot.h" ! #include "coord.h" inline static void timeval_fix(coord *r) { *************** *** 178,236 **** coord timeval_round_down(coord c1, coord c2) { coord r; struct tm *tmp; - time_t gmtoff; tmp = localtime((time_t *) &(c1.t.tv_sec)); #ifdef TM_GMTOFF c1.t.tv_sec += tmp->tm_gmtoff; #endif - if (tmp->tm_isdst==0) { - gmtoff = -timezone; - } else if (tmp->tm_isdst==1) { - gmtoff = -altzone; - } else { - gmtoff = 0; - } - c1.t.tv_sec += gmtoff; if (c2.t.tv_sec == 0) { r.t.tv_sec = c1.t.tv_sec; r.t.tv_usec = (c1.t.tv_usec - (c1.t.tv_usec % c2.t.tv_usec)); } else { r.t.tv_usec = 0; r.t.tv_sec = c1.t.tv_sec - (c1.t.tv_sec % c2.t.tv_sec); } ! r.t.tv_sec -= gmtoff; timeval_fix(&r); return r; } coord timeval_round_up(coord c1, coord c2) { coord r; struct tm *tmp; - time_t gmtoff; tmp = localtime((time_t *) &(c1.t.tv_sec)); #ifdef TM_GMTOFF c1.t.tv_sec += tmp->tm_gmtoff; #endif - if (tmp->tm_isdst==0) { - gmtoff = -timezone; - } else if (tmp->tm_isdst==1) { - gmtoff = -altzone; - } else { - gmtoff = 0; - } - c1.t.tv_sec += gmtoff; if (c2.t.tv_sec == 0) { r.t.tv_sec = c1.t.tv_sec; if (c1.t.tv_usec % c2.t.tv_usec == 0) r.t.tv_usec = c1.t.tv_usec; --- 169,212 ---- coord timeval_round_down(coord c1, coord c2) { coord r; struct tm *tmp; tmp = localtime((time_t *) &(c1.t.tv_sec)); + #ifdef TM_GMTOFF c1.t.tv_sec += tmp->tm_gmtoff; #endif if (c2.t.tv_sec == 0) { r.t.tv_sec = c1.t.tv_sec; r.t.tv_usec = (c1.t.tv_usec - (c1.t.tv_usec % c2.t.tv_usec)); } else { r.t.tv_usec = 0; r.t.tv_sec = c1.t.tv_sec - (c1.t.tv_sec % c2.t.tv_sec); } ! #ifdef TM_GMTOFF ! r.t.tv_sec -= tmp->tm_gmtoff; ! #endif timeval_fix(&r); return r; } coord timeval_round_up(coord c1, coord c2) { coord r; struct tm *tmp; tmp = localtime((time_t *) &(c1.t.tv_sec)); #ifdef TM_GMTOFF c1.t.tv_sec += tmp->tm_gmtoff; #endif if (c2.t.tv_sec == 0) { r.t.tv_sec = c1.t.tv_sec; if (c1.t.tv_usec % c2.t.tv_usec == 0) r.t.tv_usec = c1.t.tv_usec; *************** *** 248,258 **** r.t.tv_sec = c1.t.tv_sec; else r.t.tv_sec = c1.t.tv_sec + (c2.t.tv_sec - (c1.t.tv_sec % c2.t.tv_sec)); } ! r.t.tv_sec -= gmtoff; timeval_fix(&r); return r; #if 0 --- 224,236 ---- r.t.tv_sec = c1.t.tv_sec; else r.t.tv_sec = c1.t.tv_sec + (c2.t.tv_sec - (c1.t.tv_sec % c2.t.tv_sec)); } ! #ifdef TM_GMTOFF ! r.t.tv_sec -= tmp->tm_gmtoff; ! #endif timeval_fix(&r); return r; #if 0 *************** *** 323,333 **** }; coord timeval_tick(int level) { coord r; ! extern void ianic(); if (level < 0 || level >= sizeof(tick_table) / sizeof(struct tick_table_s)) panic("timeval_tick: level too large"); --- 301,311 ---- }; coord timeval_tick(int level) { coord r; ! extern void panic(); if (level < 0 || level >= sizeof(tick_table) / sizeof(struct tick_table_s)) panic("timeval_tick: level too large");