I am using AwesomeWM v4.0-170-g6c24848-dirty, compiled against Lua 5.3.3; and I am starting to customise my widgets.
One of them is the clock, technically wibox.widget.textclock()
. I have been able to alter the format
in order to change the order, add custom messages like 'Today is Sunday, the 23 of July of 2017' but... no clue about the ordinals.
What I mean here is how to add that 'rd' to 23rd, and make it change depending on the current date to, for example, 21st, 22nd or 24th.
I have tried to add an ordinal
variable before the format, followed to an if-else statement to determine its value depending on the day. This, however, does not work: I can't neither 'use' the date format outside the function, nor implement the variable inside format
.
As far as I have read, variables in strings can be implemented like in the following example:
print("Hello " .. name .. ", the value of key " .. k .. " is " .. v .. "!")
However, this won't work here. I have run out of clues, can you shed me a light, please?
So far, I have coded a generic 'th' date format:
mytextclock = wibox.widget.textclock(" %a %dth %B, %H:%M ", 60)
...whose output would be: dayoftheweek dayth month, HH, MM.