Skip to content

Instantly share code, notes, and snippets.

@ldante86
Created November 7, 2016 20:53
Show Gist options
  • Save ldante86/aacf300cc0c9aa593b279fdc87cb48a2 to your computer and use it in GitHub Desktop.
Save ldante86/aacf300cc0c9aa593b279fdc87cb48a2 to your computer and use it in GitHub Desktop.
locale ideas for lcal
#!/bin/bash -
short_weekdays=$(locale -c LC_TIME | sed -n '2p')
long_weekdays=$(locale -c LC_TIME | sed -n '3p')
short_months=$(locale -c LC_TIME | sed -n '4p')
long_months=$(locale -c LC_TIME | sed -n '5p')
unset gweek_header
unset jweek_header
unset DAYS
unset MONTH_LIST
unset LONG_MONTH_LIST
OLDIFS="$IFS"
IFS=";"
for i in $short_weekdays; do gweek_header+=( "${i:0:2}" ); done
for i in $short_weekdays; do jweek_header+=( "$i" ); done
for i in $long_weekdays; do DAYS+=( "$i" ); done
for i in $short_months; do MONTH_LIST+=( "$i" ); done
for i in $long_months; do LONG_MONTH_LIST+=( "$i" ); done
gweek_header="${gweek_header[@]}"
jweek_header="${jweek_header[@]}"
IFS="$OLDIFS"
config=lcal.locale
{
echo "DAYS=( ${DAYS[@]} )"
echo "MONTH_LIST=( ${MONTH_LIST[@]} )"
echo "LONG_MONTH_LIST=( ${LONG_MONTH_LIST[@]} )"
echo "gweek_header=( $gweek_header )"
echo "jweek_header=( $jweek_header )"
} #> $config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment