Code snippet to get fancy with fantasy dates

grumbleputty
21 Jan 2023, 19:50

Simple, but hopefully it helps someone out. Let's you change the names of the months easily, and formats the date so it reads "The Xth of X, of the year XXXX"

-requires the Pixie's exceptional Clocklib.aslx

 <function name="DisplayDate" parameters="year, month, day" type="string">
    months = Split(";Blainchill;Frostmarch;Bloomspread;Suncrisp;Stormwrack;Meadowhaze;Glare;Sunhallow;Longshadow;Grimm;Chillwind;Fallflake", ";")
    switch (day) {
      case (1) {
        suffix = "st"
      }
      case (2) {
        suffix = "nd"
      }
      case (3) {
        suffix = "rd"
      }
      default {
        suffix = "th"
      }
    }
    return ("The " + day + suffix+" of " + StringListItem(months, month) + ",  of the year " + year)
  </function>```

Doctor Agon
02 Feb 2023, 10:41

Does this code handle '11th, 12th, 13th', and '21st, 22nd, 23rd, 31st'


mrangel
02 Feb 2023, 19:06

Does this code handle '11th, 12th, 13th', and '21st, 22nd, 23rd, 31st'

      case (1,21,31) {
        suffix = "st"
      }
      case (2,22) {
        suffix = "nd"
      }
      case (3,23) {
        suffix = "rd"
      }
      default {
        suffix = "th"
      }

grumbleputty
05 Feb 2023, 18:21

good catch both of you!