add mdate, a portable version of GNU date --rfc-2822

This commit is contained in:
Christian Neukirchen 2016-08-08 14:01:05 +02:00
parent 55c823f89a
commit 2a72a341c0
2 changed files with 17 additions and 1 deletions

View File

@ -1,11 +1,12 @@
CFLAGS=-g -O2 -Wall -Wno-switch -Wextra -fstack-protector-strong -D_FORTIFY_SOURCE=2 CFLAGS=-g -O2 -Wall -Wno-switch -Wextra -fstack-protector-strong -D_FORTIFY_SOURCE=2
ALL = maddr magrep mdeliver mdirs mflag mgenmid mhdr minc mlist mmime mpick mscan msed mseq mshow msort mthread ALL = maddr magrep mdate mdeliver mdirs mflag mgenmid mhdr minc mlist mmime mpick mscan msed mseq mshow msort mthread
all: $(ALL) all: $(ALL)
maddr: maddr.o blaze822.o seq.o rfc2047.o mymemmem.o maddr: maddr.o blaze822.o seq.o rfc2047.o mymemmem.o
magrep: magrep.o blaze822.o seq.o rfc2045.o rfc2047.o mymemmem.o magrep: magrep.o blaze822.o seq.o rfc2045.o rfc2047.o mymemmem.o
mdate: mdate.o
mdeliver: mdeliver.o blaze822.o mymemmem.o mdeliver: mdeliver.o blaze822.o mymemmem.o
mdirs: mdirs.o mdirs: mdirs.o
mflag: mflag.o blaze822.o seq.o mymemmem.o mflag: mflag.o blaze822.o seq.o mymemmem.o

15
mdate.c Normal file
View File

@ -0,0 +1,15 @@
#include <time.h>
#include <unistd.h>
int
main() {
char buf[64];
time_t now = time(0);
ssize_t l = strftime(buf, sizeof buf,
"%a, %d %b %Y %T %z\n", localtime(&now));
if (write(1, buf, l) == l)
return 0;
return 1;
}