From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: ztrftime() fix
Date: Thu, 06 Mar 1997 15:54:39 +0100 [thread overview]
Message-ID: <199703061454.PAA28669@hydra.ifh.de> (raw)
A quick poll of workstations in the south-east Zeuthen area reveals
that it is standard for strftime() formats which can return one or two
digits, namely %e and %k, to precede the former by a space to maintain
the character count.
Zsh hijacks these and omits the space, even where it makes the promise
(as in the prompt code) to use strftime() for formatting. I'd prefer
to use different letters for the code where the length is not
preserved. I've invented %K for %k and %f for %e (sorry, %E is used
by the locale code in Solaris) which seem to be free. I've adapted
the rest of the code to use these where the intention was to omit the
extra space in prompts etc., but left it in the sched code where
presumably the intention is to emulate ctime(), which always produces
the extra space (or even a zero on some machines).
Maybe there are even standard letters for these on SuperDuperIX
1,000,009?
(The reason I noticed this is I'm writing a stat module which I might
post.)
*** Doc/Zsh/prompt.yo.space Wed Jan 29 16:41:32 1997
--- Doc/Zsh/prompt.yo Thu Mar 6 15:38:22 1997
***************
*** 95,101 ****
)
item(tt(%D{)var(string)tt(}))(
var(string) is formatted using the tt(strftime) function.
! See manref(strftime)(3) for more details.
)
item(tt(%l))(
The line (tty) the user is logged in on.
--- 95,104 ----
)
item(tt(%D{)var(string)tt(}))(
var(string) is formatted using the tt(strftime) function.
! See manref(strftime)(3) for more details. Two additional codes are
! available: tt(%f) prints the day of the month, like tt(%e) but
! without any preceding space if the day is a single digit, and tt(%K)
! corresponds to tt(%k) for the hour of the day in the same way.
)
item(tt(%l))(
The line (tty) the user is logged in on.
*** Src/prompt.c.space Thu Jan 23 16:37:27 1997
--- Src/prompt.c Thu Mar 6 15:27:04 1997
***************
*** 476,488 ****
switch (*fm) {
case 'T':
! tmfmt = "%k:%M";
break;
case '*':
! tmfmt = "%k:%M:%S";
break;
case 'w':
! tmfmt = "%a %e";
break;
case 'W':
tmfmt = "%m/%d/%y";
--- 476,488 ----
switch (*fm) {
case 'T':
! tmfmt = "%K:%M";
break;
case '*':
! tmfmt = "%K:%M:%S";
break;
case 'w':
! tmfmt = "%a %f";
break;
case 'W':
tmfmt = "%m/%d/%y";
*** Src/utils.c.space Tue Feb 18 16:29:57 1997
--- Src/utils.c Thu Mar 6 15:43:43 1997
***************
*** 1307,1319 ****
--- 1307,1325 ----
*buf++ = '0' + tm->tm_mday % 10;
break;
case 'e':
+ case 'f':
if (tm->tm_mday > 9)
*buf++ = '0' + tm->tm_mday / 10;
+ else if (fmt[-1] == 'e')
+ *buf++ = ' ';
*buf++ = '0' + tm->tm_mday % 10;
break;
case 'k':
+ case 'K':
if (tm->tm_hour > 9)
*buf++ = '0' + tm->tm_hour / 10;
+ else if (fmt[-1] == 'k')
+ *buf++ = ' ';
*buf++ = '0' + tm->tm_hour % 10;
break;
case 'l':
*** Src/watch.c.space Sun Jan 5 22:07:31 1997
--- Src/watch.c Thu Mar 6 15:27:54 1997
***************
*** 191,200 ****
fm2 = "%l:%M%p";
break;
case 'T':
! fm2 = "%k:%M";
break;
case 'w':
! fm2 = "%a %e";
break;
case 'W':
fm2 = "%m/%d/%y";
--- 191,200 ----
fm2 = "%l:%M%p";
break;
case 'T':
! fm2 = "%K:%M";
break;
case 'w':
! fm2 = "%a %f";
break;
case 'W':
fm2 = "%m/%d/%y";
--
Peter Stephenson <pws@ifh.de> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
reply other threads:[~1997-03-06 15:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199703061454.PAA28669@hydra.ifh.de \
--to=pws@ifh.de \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).