Ruby, (削除) 99 89 (削除ここまで) 102 bytes
->y,m{(1..4).find{|d|(A=Date.new y,m,-d).wday<5}
A.strftime"%A %d#{A.day>30?'st':'th'}"}
require'time'
Explanation
Anonymous function tacking year and month as numbers.
We find which of the last 4 days of month ( checking backwards using -d ) are wdays (week days 0-indexed) less than 5 saving each time date object in constant A for later use.
When it's found loop is stopped so A is the last weekday of the month.
Then we format the output, we can only have 31th31st or xxstXXth.
Ruby, (削除) 99 89 (削除ここまで) 102 bytes
->y,m{(1..4).find{|d|(A=Date.new y,m,-d).wday<5}
A.strftime"%A %d#{A.day>30?'st':'th'}"}
require'time'
Explanation
Anonymous function tacking year and month as numbers.
We find which of the last 4 days of month ( checking backwards using -d ) are wdays (week days 0-indexed) less than 5 saving each time date object in constant A for later use.
When it's found loop is stopped so A is the last weekday of the month.
Then we format the output, we can only have 31th or xxst
Ruby, (削除) 99 89 (削除ここまで) 102 bytes
->y,m{(1..4).find{|d|(A=Date.new y,m,-d).wday<5}
A.strftime"%A %d#{A.day>30?'st':'th'}"}
require'time'
Explanation
Anonymous function tacking year and month as numbers.
We find which of the last 4 days of month ( checking backwards using -d ) are wdays (week days 0-indexed) less than 5 saving each time date object in constant A for later use.
When it's found loop is stopped so A is the last weekday of the month.
Then we format the output, we can only have 31st or XXth.
Ruby, (削除) 99 89 (削除ここまで) 117102 bytes
->y,m{(a=(Date1.new(y).4).Datefind{|d|(A=Date.new(y,m,-1)d).reject{|d|d.wday>4wday<5}[-1])
A.strftime"%A %d#{aA.day>30?'st':'th'}"}
require'time'
Fixed restricted output at huge cost.
Never thought Ruby had ranges also for dates!Try it online!
Explanation
Anonymous function tacking year and month as numbers.
We pass the [First dayfind which of year ..the last day4 days of month( checking backwards using -1d )] range and reject wdays are wdays (week days 0-indexed) greater then 4less than 5 saving each time date object in constant A for later use.
We returnWhen it's found loop is stopped so A is the last elementweekday of the month.
Then we format the output, we can only have 31th or xxst
Ruby, (削除) 99 89 (削除ここまで) 117 bytes
->y,m{(a=(Date.new(y)..Date.new(y,m,-1)).reject{|d|d.wday>4}[-1]).strftime"%A %d#{a.day>30?'st':'th'}"}
require'time'
Fixed restricted output at huge cost.
Never thought Ruby had ranges also for dates!
Explanation
Anonymous function tacking year and month as numbers.
We pass the [First day of year .. last day of month(-1)] range and reject wdays(week days 0-indexed) greater then 4.
We return the last element.
Ruby, (削除) 99 89 (削除ここまで) 102 bytes
->y,m{(1..4).find{|d|(A=Date.newy,m,-d).wday<5}
A.strftime"%A %d#{A.day>30?'st':'th'}"}
require'time'
Explanation
Anonymous function tacking year and month as numbers.
We find which of the last 4 days of month( checking backwards using -d ) are wdays (week days 0-indexed) less than 5 saving each time date object in constant A for later use.
When it's found loop is stopped so A is the last weekday of the month.
Then we format the output, we can only have 31th or xxst
Ruby, (削除) 99 89 (削除ここまで) 131117 bytes
->y,m{(a=(Date.new(y)..Date.new(y,m,-1)).reject{|d|d.wday>4}[-1]).strftime"%A %-d#%d#{%w(th st nd rd)[aa.day%10]||'th'day>30?'st':'th'}"}
require'time'
Fixed restricted output at huge cost.
Never thought Ruby had ranges also for dates!
Explanation
Anonymous function tacking year and month as numbers.
We pass the [First day of year .. last day of month(-1)] range and reject wdays(week days 0-indexed) greater then 4.
We return the last element.
Ruby, (削除) 99 89 (削除ここまで) 131 bytes
->y,m{(a=(Date.new(y)..Date.new(y,m,-1)).reject{|d|d.wday>4}[-1]).strftime"%A %-d#{%w(th st nd rd)[a.day%10]||'th'}"}
require'time'
Fixed restricted output at huge cost.
Never thought Ruby had ranges also for dates!
Explanation
Anonymous function tacking year and month as numbers.
We pass the [First day of year .. last day of month(-1)] range and reject wdays(week days 0-indexed) greater then 4.
We return the last element.
Ruby, (削除) 99 89 (削除ここまで) 117 bytes
->y,m{(a=(Date.new(y)..Date.new(y,m,-1)).reject{|d|d.wday>4}[-1]).strftime"%A %d#{a.day>30?'st':'th'}"}
require'time'
Fixed restricted output at huge cost.
Never thought Ruby had ranges also for dates!
Explanation
Anonymous function tacking year and month as numbers.
We pass the [First day of year .. last day of month(-1)] range and reject wdays(week days 0-indexed) greater then 4.
We return the last element.