Display ordinal indicators after date.

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
mzsade
Level 5
Level 5
Posts: 776
Joined: Sun Jul 19, 2009 4:36 am

Display ordinal indicators after date.

Post by mzsade »

Found this neat little script that i put to use in my conky.conf in lieu of the conky <time> variable.. Sorry if it's nothing new for most of you but i am impressed enough by it's elegant simplicity to risk adding more clutter to the forum. :wink:

Code: Select all

#!/bin/sh
DaySuffix() {
  case `date +%d` in
    1|21|31) echo "st";;
    2|22)    echo "nd";;
    3|23)    echo "rd";;
    *)       echo "th";;
  esac
}
date "+%a, %e`DaySuffix` %b, %Y"
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Linux User #481272 Reg: 15th Sept., 2008
User avatar
mzsade
Level 5
Level 5
Posts: 776
Joined: Sun Jul 19, 2009 4:36 am

Re: Display ordinal indicators after date.

Post by mzsade »

The script had a bug, noticed it on the first of March when it began lisping. Fixed it,

Code: Select all

#!/bin/bash
Odin() {
  case `date +%d` in
    ?1|21|31) echo "st" ;;
    ?2|22)    echo "nd" ;;
    ?3|23)    echo "rd" ;;
    *)        echo "th" ;;
  esac
}
date "+%a, %e`Odin` %b, %Y"
Edit: My bad, the bug was still there, noticed it today when the script acquired a Russian accent, this one's totally bug free, Honest Injun!

Code: Select all

#!/bin/bash
Odin() {
  case `date +%d` in
    01|21|31) echo "st" ;;
    02|22)    echo "nd" ;;
    03|23)    echo "rd" ;;
    *)        echo "th" ;;
  esac
}
date "+%a, %e`Odin` %b, %Y"
Linux User #481272 Reg: 15th Sept., 2008
Locked

Return to “Compiz, Conky, Docks & Widgets”