Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

ztrftime() fix



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@xxxxxx>       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.



Messages sorted by: Reverse Date, Date, Thread, Author