updated on Mon Jan 16 04:00:32 UTC 2012
[aur-mirror.git] / qmail / qmail-date-localtime.patch
blobe1713888a5a6da6d40c82bf5478a996a9a34ca88
1 This patch causes the various qmail programs to generate date stamps in
2 the local timezone. I find GMT too annoying to convert from/to. I make
3 no warranties that it will work in your timezone, however it works for me.
5 Works with qmail 1.01 to 1.03.
7 To apply this patch, cd into the qmail source directory and type...
8 patch -s -p1 < patch-to-patch-file
10 --- qmail-1.03.orig/date822fmt.c Tue Apr 15 15:05:23 1997
11 +++ qmail-1.03/date822fmt.c Fri Apr 18 00:39:41 1997
12 @@ -1,3 +1,4 @@
13 +#include <time.h>
14 #include "datetime.h"
15 #include "fmt.h"
16 #include "date822fmt.h"
17 @@ -12,18 +13,51 @@
19 unsigned int i;
20 unsigned int len;
21 + time_t now;
22 + datetime_sec utc;
23 + datetime_sec local;
24 + struct tm *tm;
25 + struct datetime new_dt;
26 + int minutes;
28 + utc = datetime_untai(dt);
29 + now = (time_t)utc;
30 + tm = localtime(&now);
31 + new_dt.year = tm->tm_year;
32 + new_dt.mon = tm->tm_mon;
33 + new_dt.mday = tm->tm_mday;
34 + new_dt.hour = tm->tm_hour;
35 + new_dt.min = tm->tm_min;
36 + new_dt.sec = tm->tm_sec;
37 + local = datetime_untai(&new_dt);
39 len = 0;
40 - i = fmt_uint(s,dt->mday); len += i; if (s) s += i;
41 + i = fmt_uint(s,new_dt.mday); len += i; if (s) s += i;
42 i = fmt_str(s," "); len += i; if (s) s += i;
43 - i = fmt_str(s,montab[dt->mon]); len += i; if (s) s += i;
44 + i = fmt_str(s,montab[new_dt.mon]); len += i; if (s) s += i;
45 i = fmt_str(s," "); len += i; if (s) s += i;
46 - i = fmt_uint(s,dt->year + 1900); len += i; if (s) s += i;
47 + i = fmt_uint(s,new_dt.year + 1900); len += i; if (s) s += i;
48 i = fmt_str(s," "); len += i; if (s) s += i;
49 - i = fmt_uint0(s,dt->hour,2); len += i; if (s) s += i;
50 + i = fmt_uint0(s,new_dt.hour,2); len += i; if (s) s += i;
51 i = fmt_str(s,":"); len += i; if (s) s += i;
52 - i = fmt_uint0(s,dt->min,2); len += i; if (s) s += i;
53 + i = fmt_uint0(s,new_dt.min,2); len += i; if (s) s += i;
54 i = fmt_str(s,":"); len += i; if (s) s += i;
55 - i = fmt_uint0(s,dt->sec,2); len += i; if (s) s += i;
56 - i = fmt_str(s," -0000\n"); len += i; if (s) s += i;
57 + i = fmt_uint0(s,new_dt.sec,2); len += i; if (s) s += i;
59 + if (local < utc) {
60 + minutes = (utc - local + 30) / 60;
61 + i = fmt_str(s," -"); len += i; if (s) s += i;
62 + i = fmt_uint0(s,minutes / 60,2); len += i; if (s) s += i;
63 + i = fmt_uint0(s,minutes % 60,2); len += i; if (s) s += i;
64 + }
65 + else {
66 + minutes = (local - utc + 30) / 60;
67 + i = fmt_str(s," +"); len += i; if (s) s += i;
68 + i = fmt_uint0(s,minutes / 60,2); len += i; if (s) s += i;
69 + i = fmt_uint0(s,minutes % 60,2); len += i; if (s) s += i;
70 + }
72 + i = fmt_str(s,"\n"); len += i; if (s) s += i;
74 return len;