Created
November 18, 2013 02:04
-
-
Save hmkz/7521269 to your computer and use it in GitHub Desktop.
qmail-toaster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- date822fmt.c~ 1998-06-15 19:53:16.000000000 +0900 | |
+++ date822fmt.c 2010-11-17 15:10:07.000000000 +0900 | |
@@ -1,3 +1,4 @@ | |
+#include <time.h> | |
#include "datetime.h" | |
#include "fmt.h" | |
#include "date822fmt.h" | |
@@ -12,18 +13,52 @@ | |
{ | |
unsigned int i; | |
unsigned int len; | |
+ time_t now; | |
+ datetime_sec utc; | |
+ datetime_sec local; | |
+ struct tm *tm; | |
+ struct datetime new_dt; | |
+ int minutes; | |
+ | |
+ utc = datetime_untai(dt); | |
+ now = (time_t)utc; | |
+ tm = localtime(&now); | |
+ new_dt.year = tm->tm_year; | |
+ new_dt.mon = tm->tm_mon; | |
+ new_dt.mday = tm->tm_mday; | |
+ new_dt.hour = tm->tm_hour; | |
+ new_dt.min = tm->tm_min; | |
+ new_dt.sec = tm->tm_sec; | |
+ local = datetime_untai(&new_dt); | |
+ | |
len = 0; | |
- i = fmt_uint(s,dt->mday); len += i; if (s) s += i; | |
+ i = fmt_uint(s,new_dt.mday); len += i; if (s) s += i; | |
i = fmt_str(s," "); len += i; if (s) s += i; | |
- i = fmt_str(s,montab[dt->mon]); len += i; if (s) s += i; | |
+ i = fmt_str(s,montab[new_dt.mon]); len += i; if (s) s += i; | |
i = fmt_str(s," "); len += i; if (s) s += i; | |
- i = fmt_uint(s,dt->year + 1900); len += i; if (s) s += i; | |
+ i = fmt_uint(s,new_dt.year + 1900); len += i; if (s) s += i; | |
i = fmt_str(s," "); len += i; if (s) s += i; | |
- i = fmt_uint0(s,dt->hour,2); len += i; if (s) s += i; | |
+ i = fmt_uint0(s,new_dt.hour,2); len += i; if (s) s += i; | |
i = fmt_str(s,":"); len += i; if (s) s += i; | |
- i = fmt_uint0(s,dt->min,2); len += i; if (s) s += i; | |
+ i = fmt_uint0(s,new_dt.min,2); len += i; if (s) s += i; | |
i = fmt_str(s,":"); len += i; if (s) s += i; | |
- i = fmt_uint0(s,dt->sec,2); len += i; if (s) s += i; | |
- i = fmt_str(s," -0000\n"); len += i; if (s) s += i; | |
+ i = fmt_uint0(s,new_dt.sec,2); len += i; if (s) s += i; | |
+ | |
+ if (local < utc) { | |
+ minutes = (utc - local + 30) / 60; | |
+ i = fmt_str(s," -"); len += i; if (s) s += i; | |
+ i = fmt_uint0(s,minutes / 60,2); len += i; if (s) s += i; | |
+ i = fmt_uint0(s,minutes % 60,2); len += i; if (s) s += i; | |
+ } | |
+ else { | |
+ minutes = (local - utc + 30) / 60; | |
+ i = fmt_str(s," +"); len += i; if (s) s += i; | |
+ i = fmt_uint0(s,minutes / 60,2); len += i; if (s) s += i; | |
+ i = fmt_uint0(s,minutes % 60,2); len += i; if (s) s += i; | |
+ } | |
+ | |
+ i = fmt_str(s,"\n"); len += i; if (s) s += i; | |
+ | |
+ | |
return len; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment