Code snippet to get fancy with fantasy dates

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>```

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


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"
      }

good catch both of you!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums