=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/Attic/rcstime.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** src/usr.bin/cvs/Attic/rcstime.c 2006/03/09 16:53:56 1.2 --- src/usr.bin/cvs/Attic/rcstime.c 2006/04/13 19:16:15 1.3 *************** *** 1,4 **** ! /* $OpenBSD: rcstime.c,v 1.2 2006/03/09 16:53:56 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: rcstime.c,v 1.3 2006/04/13 19:16:15 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * All rights reserved. *************** *** 29,75 **** #include "log.h" #include "rcs.h" ! ! struct tm * ! rcs_set_tz(char *tz, struct rcs_delta *rdp) { int tzone; char *h, *m; ! struct tm *tb, ltb; time_t now; - tb = &rdp->rd_date; - if (!strcmp(tz, "LT")) { now = mktime(&rdp->rd_date); ! tb = localtime(&now); ! tb->tm_hour += ((int)tb->tm_gmtoff/3600); } else { switch (*tz) { case '-': ! case '+': break; default: fatal("%s: not a known time zone", tz); } ! h = tz; if ((m = strrchr(tz, ':')) != NULL) *(m++) = '\0'; ! ltb = rdp->rd_date; ! tb = <b; tzone = atoi(h); if ((tzone >= 24) && (tzone <= -24)) fatal("%s: not a known time zone", tz); ! tb->tm_hour += tzone; ! if ((tb->tm_hour >= 24) && (tb->tm_hour <= -24)) tb->tm_hour = 0; - tb->tm_gmtoff += (tzone*3600); - if (m != NULL) { tzone = atoi(m); if (tzone >= 60) --- 29,82 ---- #include "log.h" #include "rcs.h" ! void ! rcs_set_tz(char *tz, struct rcs_delta *rdp, struct tm *tb) { int tzone; + int neg, pos; char *h, *m; ! struct tm *ltb; time_t now; if (!strcmp(tz, "LT")) { now = mktime(&rdp->rd_date); ! ltb = localtime(&now); ! ltb->tm_hour += ((int)ltb->tm_gmtoff/3600); ! memcpy(tb, ltb, sizeof(struct tm)); } else { + neg = pos = 0; switch (*tz) { case '-': ! neg = 1; break; + case '+': + pos = 1; + break; default: fatal("%s: not a known time zone", tz); } ! h = (tz + 1); if ((m = strrchr(tz, ':')) != NULL) *(m++) = '\0'; ! memcpy(tb, &rdp->rd_date, sizeof(struct tm)); tzone = atoi(h); if ((tzone >= 24) && (tzone <= -24)) fatal("%s: not a known time zone", tz); ! if (pos) { ! tb->tm_hour += tzone; ! tb->tm_gmtoff += (tzone * 3600); ! } else { ! tb->tm_hour -= tzone; ! tb->tm_gmtoff -= (tzone * 3600); ! } ! ! if ((tb->tm_hour >= 24) || (tb->tm_hour <= -24)) tb->tm_hour = 0; if (m != NULL) { tzone = atoi(m); if (tzone >= 60) *************** *** 77,89 **** if ((tb->tm_min + tzone) >= 60) { tb->tm_hour++; ! tb->tm_min -= tzone; } else tb->tm_min += tzone; tb->tm_gmtoff += (tzone*60); } } - - return (tb); } --- 84,94 ---- if ((tb->tm_min + tzone) >= 60) { tb->tm_hour++; ! tb->tm_min -= (60 - tzone); } else tb->tm_min += tzone; tb->tm_gmtoff += (tzone*60); } } }