From 3322d89b340a31be802230a7be196292eb9a2094 Mon Sep 17 00:00:00 2001 From: joerg Date: Fri, 28 Jan 2000 17:40:42 +0000 Subject: 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 --- lib/libc/stdtime/strftime.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/libc/stdtime/strftime.c') 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; -- cgit v1.1