summaryrefslogtreecommitdiff
path: root/sys/src/cmd/upas/imap4d/print.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2020-09-26 11:20:42 -0700
committerOri Bernstein <ori@eigenstate.org>2020-09-26 11:20:42 -0700
commitd9f9e10e7b3ad61342ec1d9b034dd17f8452ccbc (patch)
tree3a0b155a8b2273cfe41110fe0a15ce50d6eb1e4f /sys/src/cmd/upas/imap4d/print.c
parent9afa5550f7497f84fb157ba07ff94301dbe06bcc (diff)
upas: convert to tmdate, change timezone format
Complete the conversion of upas to remove ctime, use the new date library, and print time zones in +hhmm format, instead of NNN format. This may affect code that expects specific names for timezones. Fix that code.
Diffstat (limited to 'sys/src/cmd/upas/imap4d/print.c')
-rw-r--r--sys/src/cmd/upas/imap4d/print.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/sys/src/cmd/upas/imap4d/print.c b/sys/src/cmd/upas/imap4d/print.c
index 80580ad14..2fd883d5a 100644
--- a/sys/src/cmd/upas/imap4d/print.c
+++ b/sys/src/cmd/upas/imap4d/print.c
@@ -90,40 +90,25 @@ Xfmt(Fmt *f)
return fmtstrcpy(f, encfs(buf, sizeof buf, s));
}
-static char *day[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
-};
-
-static char *mon[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
-};
-
int
Dfmt(Fmt *f)
{
- char buf[128], *p, *e, *sgn, *fmt;
- int off;
- Tm *tm;
+ char buf[128], *fmt;
+ Tm *tm, t;
+ Tzone *tz;
tm = va_arg(f->args, Tm*);
- if(tm == nil)
- tm = localtime(time(0));
- sgn = "+";
- if(tm->tzoff < 0)
- sgn = "";
- e = buf + sizeof buf;
- p = buf;
- off = (tm->tzoff/3600)*100 + (tm->tzoff/60)%60;
+ if(tm == nil){
+ tz = tzload("local");
+ tm = tmtime(&t, time(0), tz);
+ }
if((f->flags & FmtSharp) == 0){
/* rfc822 style */
- fmt = "%.2d %s %.4d %.2d:%.2d:%.2d %s%.4d";
- p = seprint(p, e, "%s, ", day[tm->wday]);
+ fmt = "WW, DD MMM YYYY hh:mm:ss Z";
}else
- fmt = "%2d-%s-%.4d %2.2d:%2.2d:%2.2d %s%4.4d";
- seprint(p, e, fmt,
- tm->mday, mon[tm->mon], tm->year + 1900, tm->hour, tm->min, tm->sec,
- sgn, off);
+ fmt = "DD-MMM-YYYY hh:mm:ss Z";
if(f->r == L'δ')
- return fmtstrcpy(f, buf);
+ return fmtprint(f, "%τ", tmfmt(tm, fmt));
+ snprint(buf, sizeof(buf), "%τ", tmfmt(tm, fmt));
return fmtprint(f, "%Z", buf);
}