Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Date prompt expansion
> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author