From: Mark van Dijk <lists+zsh@internecto.net>
To: zsh-users@zsh.org
Subject: Re: Date prompt expansion
Date: Mon, 26 Nov 2012 13:38:04 +0100 [thread overview]
Message-ID: <50B362AC.4000203@internecto.net> (raw)
In-Reply-To: <20121126114659.7ec8f1a8@pwslap01u.europe.root.pri>
> zmodload zsh/datetime
> strftime -s yesterdaysDay "+%d" $(( EPOCHSECONDS - 24 * 60 * 60 ))
Great, I'll give this a go. Thanks!
I noticed something odd when I was trying to fill an associated array
with these prompt expansions and the behaviour replicates into non-array
variable assignments too. I suspect this is caused by a bug somewhere..
Kind regards,
Mark
=====
typeset -A datetime DATETIME DateTime dATEtIME
datetime=("month" "${(%):-%D{"%m"}}"
"day" "${(%):-%D{"%d"}}"
"ymdt" "${(%):-%D{"%y%m%dT%H:%M"}}")
DATETIME=("month" "${(%):-%D{%m}}"
"day" "${(%):-%D{%d}}"
"ymdt" "${(%):-%D{%y%m%dT%H:%M}}")
DateTime=("month" ${(%):-%D{"%m"}}
"day" ${(%):-%D{"%d"}}
"ymdt" ${(%):-%D{"%y%m%dT%H:%M"}})
dATEtIME=("month" ${(%):-%D{%m}}
"day" ${(%):-%D{%d}}
"ymdt" ${(%):-%D{%y%m%dT%H:%M}})
monthday="${(%):-%D{"%m%d"}}"
MONTHDAY="${(%):-%D{%m%d}}"
MonthDay=${(%):-%D{"%m%d"}}
mONTHdAY=${(%):-%D{%m%d}}
for i (${(k)datetime}) echo "datetime[$i]: ${datetime[$i]}"
for i (${(k)DATETIME}) echo "DATETIME[$i]: ${DATETIME[$i]}"
for i (${(k)DateTime}) echo "DateTime[$i]: ${DateTime[$i]}"
for i (${(k)dATEtIME}) echo "dATEtIME[$i]: ${dATEtIME[$i]}"
echo "monthday: $monthday"
echo "MONTHDAY: $MONTHDAY"
echo "MonthDay: $MonthDay"
echo "mONTHdAY: $mONTHdAY"
=====
Output:
datetime[ymdt]: 121126T13:35}
datetime[day]: 26}
datetime[month]: 11}
DATETIME[ymdt]: 121126T13:35}
DATETIME[day]: 26}
DATETIME[month]: 11}
^ notice the } at the end
DateTime[ymdt]: 121126T13:35
DateTime[day]: 26
DateTime[month]: 11
dATEtIME[ymdt]: 121126T13:35
dATEtIME[day]: 26
dATEtIME[month]: 11
^ correct
monthday: 1126}
MONTHDAY: 1126}
MonthDay: 1126
mONTHdAY: 1126
^ same thing for normal variable assignment
next prev parent reply other threads:[~2012-11-26 12:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-26 11:33 Mark van Dijk
2012-11-26 11:46 ` Peter Stephenson
2012-11-26 12:38 ` Mark van Dijk [this message]
2012-11-26 13:01 ` Peter Stephenson
2012-11-26 16:15 ` Aaron Schrab
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=50B362AC.4000203@internecto.net \
--to=lists+zsh@internecto.net \
--cc=zsh-users@zsh.org \
/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).