Operating System - Linux
1752571 Members
5309 Online
108788 Solutions
New Discussion юеВ

Re: Get last months month in alpha?

 
SOLVED
Go to solution
A. Clay Stephenson
Acclaimed Contributor

Re: Get last months month in alpha?

I would prefer a more portable version that leverages "locale LC_TIME" for NLS but that's just me. With caljd.sh you get that for free.
If it ain't broke, I can fix that.
Dennis Handly
Acclaimed Contributor

Re: Get last months month in alpha?

>Clay: I would prefer a more portable version that leverages "locale LC_TIME"

You could take the output from "locale abday", strip the ";" and double quotes and fill your array.
$ set -A WEEKDAY $(locale abday | sed -e 's/[;"]/ /g')
$ echo ${WEEKDAY[@]}
Sun Mon Tue Wed Thu Fri Sat
Dennis Handly
Acclaimed Contributor

Re: Get last months month in alpha?

Oops, Coolmar wanted months:
$ set -A MONTHS $(locale abmon | sed -e 's/[;"]/ /g')
$ echo ${MONTHS[*]}
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

And to print out last month:
echo ${MONTHS[($(date +%m)+10)%12]}
Coolmar
Esteemed Contributor

Re: Get last months month in alpha?

Thanks everyone for all the suggestions!