summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdtime/strftime.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2000-01-28 17:40:42 +0000
committerjoerg <joerg@FreeBSD.org>2000-01-28 17:40:42 +0000
commit3322d89b340a31be802230a7be196292eb9a2094 (patch)
tree3f175ba1ff6cd113dbd7c690f72d03ae361d35d0 /lib/libc/stdtime/strftime.c
parent6dd36cc401fc851760a6fd808a3e3463126f1d3c (diff)
downloadFreeBSD-src-3322d89b340a31be802230a7be196292eb9a2094.zip
FreeBSD-src-3322d89b340a31be802230a7be196292eb9a2094.tar.gz
There were so far only 42 different conversion specifications in
strftime(3), add another one. :) %z yields the local timezone's offset in hours and minutes, as used in RFC822 headers. There's a precedence for this in Lunux' libc, and Internet software (like Perl scripts) start using it. OKed by (wrt. the code freeze): jkh
Diffstat (limited to 'lib/libc/stdtime/strftime.c')
-rw-r--r--lib/libc/stdtime/strftime.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libc/stdtime/strftime.c b/lib/libc/stdtime/strftime.c
index 9aa891f..6404d9c 100644
--- a/lib/libc/stdtime/strftime.c
+++ b/lib/libc/stdtime/strftime.c
@@ -397,6 +397,22 @@ label:
pt, ptlim);
} else pt = _add("?", pt, ptlim);
continue;
+ case 'z':
+ {
+ long absoff;
+ if (t->tm_gmtoff >= 0) {
+ absoff = t->tm_gmtoff;
+ pt = _add("+", pt, ptlim);
+ } else {
+ absoff = -t->tm_gmtoff;
+ pt = _add("-", pt, ptlim);
+ }
+ pt = _conv(absoff / 3600, "%02d",
+ pt, ptlim);
+ pt = _conv((absoff % 3600) / 60, "%02d",
+ pt, ptlim);
+ };
+ continue;
case '+':
pt = _fmt(Locale->date_fmt, t, pt, ptlim);
continue;
OpenPOWER on IntegriCloud