summaryrefslogtreecommitdiff
path: root/devel/cvs-devel/files/patch-date_format_option
blob: d78f5988328f1d8fcbe069de95eb636bb72064d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#
# Add an extra option to set the DateFormat used in log output.
#
# Patch by Steve McIntyre <steve@einval.com>
diff -Nur doc/cvs.texinfo doc/cvs.texinfo
--- doc/cvs.texinfo	2005-09-23 10:02:53.000000000 +0800
+++ doc/cvs.texinfo	2006-02-26 23:03:05.000000000 +0800
@@ -14840,9 +14840,17 @@
 group to using @code{cvs admin} to change the default keyword
 substitution mode, lock revisions, unlock revisions, and
 replace the log message, use @samp{UserAdminOptions=klum}.
-@end table
-
 
+@cindex DateFormat, in CVSROOT/config
+@item DateFormat=@var{value}
+Control the output format of dates from cvs. cvs version 1.12.x
+changed the default format to use ``iso8601'' dates, which are
+better for many reasons. However, old scripts/programs written to
+parse the output of various cvs commands (especially cvs log) may
+not cope with the change in date format (e.g. gcvs). The default
+value of DateFormat will be ``iso8601'', but if you need temporary
+backwards-compatibility set DateFormat=old.
+@end table
 
 @c ---------------------------------------------------------------------
 @node Environment variables
diff -Nur src/log.c src/log.c
--- src/log.c	2005-03-22 21:19:57.000000000 +0800
+++ src/log.c	2006-02-26 23:03:05.000000000 +0800
@@ -1607,8 +1607,12 @@
 		  &sec);
     if (year < 1900)
 	year += 1900;
-    sprintf (buf, "%04d-%02d-%02d %02d:%02d:%02d +0000", year, mon, mday,
-	     hour, min, sec);
+    if ('-' == datesep)
+        sprintf (buf, "%04d%c%02d%c%02d %02d:%02d:%02d +0000", year, datesep,
+                 mon, datesep, mday, hour, min, sec);
+    else
+        sprintf (buf, "%04d%c%02d%c%02d %02d:%02d:%02d", year, datesep,
+                 mon, datesep, mday, hour, min, sec);
     cvs_output_tagged ("date", buf);
 
     cvs_output_tagged ("text", ";  author: ");
diff -Nur src/main.c src/main.c
--- src/main.c	2006-02-26 23:03:04.000000000 +0800
+++ src/main.c	2006-02-26 23:10:12.000000000 +0800
@@ -1371,9 +1371,19 @@
     static char buf[sizeof ("yyyy-mm-dd HH:MM:SS -HHMM")];
     /* Convert to a time in the local time zone.  */
     struct tm ltm = *(localtime (&unixtime));
-
-    if (!my_strftime (buf, sizeof (buf), "%Y-%m-%d %H:%M:%S %z", &ltm, 0, 0))
-	return NULL;
+    char *format = NULL;
+  
+    switch (datesep)
+    {
+        case '/':
+            format = "%Y/%m/%d %H:%M:%S";
+            break;
+        default:
+            format = "%Y-%m-%d %H:%M:%S %z";
+            break;
+    }
+    if (my_strftime (buf, sizeof (buf), format, &ltm, 0, 0) == 0)
+        return NULL;
 
     return xstrdup (buf);
 }
@@ -1388,9 +1398,19 @@
     static char buf[sizeof ("yyyy-mm-dd HH:MM:SS -HHMM")];
     /* Convert to a time in the local time zone.  */
     struct tm ltm = *(gmtime (&unixtime));
-
-    if (!my_strftime (buf, sizeof (buf), "%Y-%m-%d %H:%M:%S %z", &ltm, 0, 0))
-	return NULL;
+    char *format = NULL;
+  
+    switch (datesep)
+    {
+        case '/':
+            format = "%Y/%m/%d %H:%M:%S";
+            break;
+        default:
+            format = "%Y-%m-%d %H:%M:%S %z";
+            break;
+    }
+    if (my_strftime (buf, sizeof (buf), format, &ltm, 0, 0) == 0)
+        return NULL;
 
     return xstrdup (buf);
 }
diff -Nur src/parseinfo.c src/parseinfo.c
--- src/parseinfo.c	2005-09-06 12:40:37.000000000 +0800
+++ src/parseinfo.c	2006-02-26 23:03:05.000000000 +0800
@@ -626,6 +626,19 @@
 		retval->logHistory = xstrdup (p);
 	    }
 	}
+    /* grab FreeBSD date format idea */
+    else if (strcmp (line, "DateFormat") == 0)
+    {
+        if (strcmp (p, "old") == 0)
+        {
+            datesep = '/';
+        }
+        else if (strcmp (p, "iso8601") == 0)
+        {
+            datesep = '-';
+        }
+    }
+    /* end grabbing */
 	else if (strcmp (line, "RereadLogAfterVerify") == 0)
 	{
 	    if (!strcasecmp (p, "never"))
diff -Nur src/rcs.c src/rcs.c
--- src/rcs.c	2006-02-26 23:03:04.000000000 +0800
+++ src/rcs.c	2006-02-26 23:03:05.000000000 +0800
@@ -33,6 +33,8 @@
 # endif
 #endif
 
+int datesep = '-';
+
 /* The RCS -k options, and a set of enums that must match the array.
    These come first so that we can use enum kflag in function
    prototypes.  */
@@ -3537,8 +3539,8 @@
 		   &sec);
     if (year < 1900)
 	year += 1900;
-    sprintf (buf, "%04d/%02d/%02d %02d:%02d:%02d", year, mon, mday,
-	     hour, min, sec);
+    sprintf (buf, "%04d%c%02d%c%02d %02d:%02d:%02d", year, datesep, mon,
+             datesep, mday, hour, min, sec);
     return xstrdup (buf);
 }
 
diff -Nur src/rcs.h src/rcs.h
--- src/rcs.h	2005-03-18 06:36:24.000000000 +0800
+++ src/rcs.h	2006-02-26 23:03:05.000000000 +0800
@@ -254,6 +254,7 @@
 void RCS_setlocalid (const char *, unsigned int, void **, const char *arg);
 char *make_file_label (const char *, const char *, RCSNode *);
 
+extern int datesep;
 extern bool preserve_perms;
 
 /* From import.c.  */