summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/util.c
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2005-12-03 15:07:22 +0000
committerJoris Vink <joris@cvs.openbsd.org>2005-12-03 15:07:22 +0000
commitc754d6bad3dea47b57c8497f2e1f3aa15cb9c3c8 (patch)
tree811ab201499114384c0627ebf0c133aac695c427 /usr.bin/cvs/util.c
parent3d78890027fb19ead4c3ba84f930b0a1bd219f96 (diff)
fix date handling in opencvs, this was broken since the very start.
now, when you checkout a tree with gnu cvs, opencvs no longer sees all the files as modified, and visa versa. this actually makes gnu cvs and opencvs dance together in working copies.
Diffstat (limited to 'usr.bin/cvs/util.c')
-rw-r--r--usr.bin/cvs/util.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index fcac258e450..30189cc4998 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.57 2005/12/03 03:59:47 joris Exp $ */
+/* $OpenBSD: util.c,v 1.58 2005/12/03 15:07:21 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -1035,3 +1035,32 @@ cvs_patchfile(const char *data, const char *patch,
cvs_freelines(plines);
return (res);
}
+
+/*
+ * a hack to mimic and thus match gnu cvs behaviour.
+ */
+time_t
+cvs_hack_time(time_t oldtime, int togmt)
+{
+ int l;
+ struct tm *t;
+ char tbuf[32];
+
+ if (togmt == 1) {
+ t = gmtime(&oldtime);
+ if (t == NULL)
+ return (0);
+
+ return (mktime(t));
+ }
+
+ t = localtime(&oldtime);
+
+ l = snprintf(tbuf, sizeof(tbuf), "%d/%d/%d GMT %d:%d:%d",
+ t->tm_mon + 1, t->tm_mday, t->tm_year + 1900, t->tm_hour,
+ t->tm_min, t->tm_sec);
+ if (l == -1 || l >= (int)sizeof(tbuf))
+ return (0);
+
+ return (cvs_date_parse(tbuf));
+}