From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5239 invoked from network); 19 Jan 1998 09:40:33 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 19 Jan 1998 09:40:33 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id EAA28461; Mon, 19 Jan 1998 04:13:53 -0500 (EST) Resent-Date: Mon, 19 Jan 1998 04:13:53 -0500 (EST) Message-Id: <199801190915.KAA25306@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: PATCH: zsh-3.1.2-zefram3: 12 hour clock (2) In-reply-to: "pws@ibmth.difi.unipi.it"'s message of "Fri, 16 Jan 1998 14:14:51 MET." <9801161314.AA38808@ibmth.difi.unipi.it> Date: Mon, 19 Jan 1998 10:15:25 +0100 From: Peter Stephenson Resent-Message-ID: <"WKoYK.0.ey6.Gbnmq"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/3730 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu pws@ibmth.difi.unipi.it wrote: > It looks (as I mentioned before) as if someone has rationalised the %l > strftime sequence to do the same as in strftime(), i.e. print a space > before a number less than 10 in an hour given in 12-hour format. > Since this makes me shriek with frustration every time I look at my > prompt, which is often, the best thing to do is probably the same as > with the 24-hour version %k, where there is an additional sequence %K > which suppresses the space. Luckily %L is free, so this makes the 12 > and 24 hour versions nicely consistent. (Historically, both %k and %l > suppressed the space, so this is also the natural way to update it.) In case anybody else has been using this, there's a slight mistake (10 is not greater than 10). Here's the corrected version. *** Doc/Zsh/prompt.yo.%L Fri Jan 16 14:26:01 1998 --- Doc/Zsh/prompt.yo Fri Jan 16 14:26:23 1998 *************** *** 103,112 **** ) 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. --- 103,113 ---- ) item(tt(%D{)var(string)tt(}))( var(string) is formatted using the tt(strftime) function. ! See manref(strftime)(3) for more details. Three 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)/tt(%L) correspond to tt(%k)/tt(%l) for the hour of the day ! (24/12 hour clock) in the same way. ) item(tt(%l))( The line (tty) the user is logged in on. *** Src/utils.c.%L Fri Jan 16 14:22:27 1998 --- Src/utils.c Mon Jan 19 10:06:55 1998 *************** *** 1318,1326 **** #else char *origbuf = buf; #endif - static char *lstr[] = - {"12", " 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", - "10", "11"}; char tmp[3]; --- 1318,1323 ---- *************** *** 1351,1357 **** *buf++ = '0' + tm->tm_hour % 10; break; case 'l': ! strucpy(&buf, lstr[tm->tm_hour % 12]); break; case 'm': *buf++ = '0' + (tm->tm_mon + 1) / 10; --- 1348,1359 ---- *buf++ = '0' + tm->tm_hour % 10; break; case 'l': ! case 'L': ! if ((tm->tm_hour % 12) > 9) ! *buf++ = '1'; ! else if (fmt[-1] == 'l') ! *buf++ = ' '; ! *buf++ = '0' + ((tm->tm_hour % 12) % 10); break; case 'm': *buf++ = '0' + (tm->tm_mon + 1) / 10; -- Peter Stephenson Tel: +39 50 911239 WWW: http://www.ifh.de/~pws/ Gruppo Teorico, Dipartimento di Fisica Piazza Torricelli 2, 56100 Pisa, Italy