summaryrefslogtreecommitdiff
path: root/sys/src/cmd/upas/Mail
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/Mail
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/Mail')
-rw-r--r--sys/src/cmd/upas/Mail/mail.c1
-rw-r--r--sys/src/cmd/upas/Mail/mesg.c13
-rw-r--r--sys/src/cmd/upas/Mail/reply.c13
3 files changed, 15 insertions, 12 deletions
diff --git a/sys/src/cmd/upas/Mail/mail.c b/sys/src/cmd/upas/Mail/mail.c
index b3fef4070..daa3ebb73 100644
--- a/sys/src/cmd/upas/Mail/mail.c
+++ b/sys/src/cmd/upas/Mail/mail.c
@@ -82,6 +82,7 @@ threadmain(int argc, char *argv[])
doquote = needsrcquote;
quotefmtinstall();
+ tmfmtinstall();
/* open these early so we won't miss notification of new mail messages while we read mbox */
plumbsendfd = plumbopen("send", OWRITE|OCEXEC);
diff --git a/sys/src/cmd/upas/Mail/mesg.c b/sys/src/cmd/upas/Mail/mesg.c
index 33d99b9b5..d9bd610cf 100644
--- a/sys/src/cmd/upas/Mail/mesg.c
+++ b/sys/src/cmd/upas/Mail/mesg.c
@@ -224,14 +224,13 @@ mesgadd(Message *mbox, char *dir, Dir *d, char *digest)
int
thisyear(char *year)
{
- static char now[10];
- char *s;
+ Tzone *tz;
+ Tm tm;
- if(now[0] == '\0'){
- s = ctime(time(nil));
- strcpy(now, s+24);
- }
- return strncmp(year, now, 4) == 0;
+ /* ignore errors: screwed means utc */
+ tz = tzload("local");
+ tmnow(&tm, tz);
+ return atoi(year) == (tm.year + 1900);
}
char*
diff --git a/sys/src/cmd/upas/Mail/reply.c b/sys/src/cmd/upas/Mail/reply.c
index 44e45fa39..9a04ed5c9 100644
--- a/sys/src/cmd/upas/Mail/reply.c
+++ b/sys/src/cmd/upas/Mail/reply.c
@@ -388,7 +388,9 @@ mesgsend(Message *m)
Channel *sync;
Message *r;
int first, nfld, delit, ofd;
- char *copy, *fld[100], *now;
+ char *copy, *fld[100];
+ Tzone *tz;
+ Tm now;
body = winreadbody(m->w, &n);
/* assemble to: list from first line, to: line, and cc: line */
@@ -467,11 +469,12 @@ mesgsend(Message *m)
ofd = open(outgoing, OWRITE|OCEXEC); /* no error check necessary */
if(ofd >= 0){
- /* From dhog Fri Aug 24 22:13:00 EDT 2001 */
- now = ctime(time(0));
- fprint(ofd, "From %s %s", user, now);
+ /* From dhog Fri Aug 24 22:13:00 +0500 2001 */
+ tz = tzload("local");
+ tmnow(&now, tz);
+ fprint(ofd, "From %s %τ", user, tmfmt(&now, "WW MMM _D hh:mm:ss Z YYYY"));
fprint(ofd, "From: %s\n", user);
- fprint(ofd, "Date: %s", now);
+ fprint(ofd, "Date: %τ", tmfmt(&now, "WW MMM _D hh:mm:ss Z YYYY"));
for(i=0; i<natt; i++)
if(included[i])
fprint(ofd, "Include: %s\n", attlist[i]);