EDIT: ChatGPT believes this to be a solution which works according to my test:
let my_date(..args) = {
// Determine the date, defaulting to today if no argument is provided.
let date = if args.pos().len() == 0 {
datetime.today()
} else {
args.pos().first()
}
// Calculate the day and determine the correct suffix.
let day = date.day()
let suffix = if day in (11, 12, 13) {
"th"
} else if calc.rem(day, 10) == 1 {
"st"
} else if calc.rem(day, 10) == 2 {
"nd"
} else if calc.rem(day, 10) == 3 {
"rd"
} else {
"th"
}
// Display the formatted date.
date.display("[day padding:none]" + suffix + " of [month repr:long] [year]")
}
Oops, you’re right, it should be calc.rem(day - 1, 10) instead of calc.rem(day, 10) - 1, I have edited my above reply. Your more explicit code by ChatGPT also works of course!