It's a yearly task, alright
PHP, 38 40 30 28 bytes
<?=date("jS F",86399*$argn);
Try it online!
Run with php -nF
input is from STDIN
. Example (above script named y.php
):
$ echo 1|php -nF y.php
1st January
$ echo 2| php -nF y.php
2nd January
$ echo 3| php -nF y.php
3rd January
$ echo 11|php -nF y.php
11th January
$ echo 21|php -nF y.php
21st January
$ echo 60|php -nF y.php
1st March
$ echo 365|php -nF y.php
31st December
Explanation
Construct an epoch timestamp for the desired day in 1970 (conveniently not a leap year) by multiplying the day number * number of seconds per day
(86400). However, this would yield one day higher so instead multiply by number of seconds in a day - 1
(86399) which for the range of input numbers (1≤n≤365) will result with the timestamp of the end of each correct day. Then just use PHP's built-in date formatting for output.
C# (Visual C# Interactive Compiler), 115 113 109 98 bytes
g=>$"{f=(g=p.AddDays(g-1)).Day}{"tsnr"[f=f%30%20<4?f%10:0]}{"htdd"[f]} {g:MMMM}";DateTime p;int f;
Thanks to @someone for saving 9 bytes
Try it online!
Jelly, 79 78 77 bytes
-1 fixing a bug :) (shouldn't pre-transpose to find index, should post-reverse, but then we can tail rather than head)
-1 using reflection (⁽©ṅB+30_2¦2
-> ⁽0ṗb4+28m0
)
⁽0ṗb4+28m0SRṁRƲœiµṪȮ%30%20«4ị“nḄƲf⁷»s3¤Ṗ,ị“£ṢtẒ⁽ẹ½MḊxɲȧėAṅ ɓaṾ¥D¹ṀẏD8÷ṬØ»Ḳ¤$K
A full program which prints the result
Try it online!
How?
will update this later...
⁽©ṅB+30_2¦2SRṁRƲZœiµḢȮ%30%20«4ị“nḄƲf⁷»s3¤Ṗ,ị“...»Ḳ¤$K - Main Link: integer, n
⁽©ṅB+30_2¦2SRṁRƲZœi - f(n) to get list of integers, [day, month]
⁽©ṅ - compressed literal 2741
B - to a list of binary digits -> [ 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]
+30 - add thirty [31,30,31,30,31,30,31,31,30,31,30,31]
¦ - sparse application...
2 - ...to indices: [2]
_ 2 - ...action: subtract two [31,28,31,30,31,30,31,31,30,31,30,31]
Ʋ - last four links as a monad - i.e. f(x):
S - sum x 365
R - range [1..365]
R - range x (vectorises) [[1..31],[1..28],...]
ṁ - mould like [[1..31],[32..59],...]
Z - transpose [[1,32,...],[2,33,...],...]
œi - 1st multi-dimensional index of n -> [day, month]
µḢȮ%30%20«4ị“nḄƲf⁷»s3¤Ṗ,ị“...»Ḳ¤$K - given [day, month] format and print
µ - start a new monadic chain - i.e. f(x=[day, month])
Ḣ - head -- get the day leaving x as [month])
Ȯ - print it (with no newline) and yield it
%30 - modulo by thirty
%20 - modulo by twenty
«4 - minimum of that and four
¤ - nilad followed by link(s) as a nilad:
“nḄƲf⁷» - dictionary words "standard"+" the" = "standard the"
s3 - split into threes = ["sta","nda","rd ","the"]
ị - index into
Ṗ - remove rightmost character
¤ - nilad followed by link(s) as a nilad:
“...» - dictionary words "January"+" February"+...
Ḳ - split at spaces = ["January","February",...]
ị - index into (vectorises across [month])
, - pair e.g. ["th", ["February"]]
K - join with spaces ["th ", "February"]
- print (implicitly smashes) th February