From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9174 invoked by alias); 28 Apr 2012 21:30:08 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17033 Received: (qmail 13756 invoked from network); 28 Apr 2012 21:30:06 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at internecto.net designates 176.9.245.29 as permitted sender) X-Virus-Scanned: Debian amavisd-new at mx1.internecto.net Date: Sat, 28 Apr 2012 23:20:11 +0200 From: Mark van Dijk To: zsh-users@zsh.org Subject: Re: can strftime show 'p.m.' instead of 'PM'? Message-ID: <20120428232011.7b2c0e9e@internecto.net> In-Reply-To: <29B9CC7BDEB94DA784265196AE5C7EEE@gmail.com> References: <29B9CC7BDEB94DA784265196AE5C7EEE@gmail.com> Organization: Internecto SIS X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; x86_64-unknown-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, 28 Apr 2012 14:55:25 -0400 TJ Luoma wrote: >=20 > Before I begin, I should say that I realize this may (seem to) be > extremely picayune, but it consistently annoys me. Judge me as you > will :-) One shall never debate the validity of taste. Unless it regards the dreadful modern popular music. But in my experience the exploration of zsh is all about, erm, "picayunicies". Pardon my spanish por favor. >=20 > `man strftime` says this: >=20 > %p is replaced by national representation of either "ante > meridiem" (a.m.) or "post meridiem" (p.m.) as appropriate. >=20 > %F is equivalent to ``%Y-%m-%d''. >=20 > %r is equivalent to ``%I:%M:%S %p''. >=20 > However when I do this in zsh >=20 > $ strftime "%F %r" "$EPOCHSECONDS" >=20 > I get this: >=20 > 2012-04-28 02:50:24 PM >=20 > Ideally I would like "PM" to be "p.m." but I'd probably settle for > "pm" >=20 > I tried using '%P' instead of '%p' (thinking that might invert the > case) but that just gave me a literal 'P' instead. >=20 > I realize that I could use: >=20 > strftime "%F %r" "$EPOCHSECONDS" | tr '[A-Z]' '[a-z]' >=20 > or even >=20 > strftime "%F %r" "$EPOCHSECONDS" | sed 's#AM#a.m#g; s#pPM#p.m.#g' >=20 > but I wondered if there was a better (more efficient) way. >=20 > Thanks >=20 > TjL I'm not sure if my idea will help you because from the looks of it this also uses strftime - but I'll share the idea anyway. You can use ZSH's prompt expansion. In the zshmisc man (although i always just 'man zshall') you can find 'Date and time' for prompt expansion. Further, zshexpn explains that you can expand these in brace expansions =C3=A1 l=C3=A0: % foo=3D'%D{%F %r}' -- this part comes from zshmisc % print ${(%)foo} -- this part comes from zshexpn 2012-04-28 10:59:15 PM So if you expand further (there are probably better methods?): % print ${${${(%)foo}/AM/a.m}/PM/p.m.} 2012-04-28 10:59:57 p.m. One thing by the way that seems to not work quite correctly from the looks of it: literally print the prompt string: % echo $(echo '%D{%F %r}') =20 %D{%F %r} -- expected, works immediately formulate the time out of it: % echo ${(%)$(echo '%D{%F %r}')}=20 2012-04-28 } -- not expected Oh well, who can blame zsh for not keeping up with this funky stuff. :) HTH - Mark