nmh-workers
[Top] [All Lists]

Re: [nmh-workers] Ordinal Indicators.

2019-07-08 06:47:38
    Date:        Mon, 08 Jul 2019 11:37:10 +0100
    From:        Ralph Corderoy <ralph@inputplus.co.uk>
    Message-ID:  <20190708103710.86F3121FEE@orac.inputplus.co.uk>

  | I had a need today to have date(1) produce 8th for today

Yes, strftime() has no ordinals, and (as best I understand it) locales
don't either.   To get them you need to code it yourself

        D=$(date +%d)
        case "$D" in
        [023]1) ORD=st;;
        [02]2)  ORD=nd;;
        [02]3)  ORD=rd;;
        *)      ORD=th;;
        esac
        case "$D" in
        0*)     SP=;;
        *)      SP=' ';;
        esac

and then deal with internationalising that for yourself... (good luck).

Then
        date "+%A, the${SP}%e${ORD} of %B"
or whatever.

kre

ps: this is not really an nmh-workers issue!


-- 
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>