Retina, 71 bytes
Byte count assumes ISO 8859-1 encoding. The trailing linefeed is significant.
(..)(..)$
$2$*¶$1
^
DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJANX
+`...¶
R-6`.
Explanation
Taking 201604
as an example:
(..)(..)$
$2$*¶$1
This swaps the last two digits of the year with the month while also expanding the month in unary using linefeeds, so we'd get:
20¶¶¶¶16
Where the ¶
represent linefeeds (0x0A).
^
DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJANX
This prepends the list of all months in reverse, as well as an X (which could be anything, really):
DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJANX20¶¶¶¶16
+`...¶
Now we repeatedly remove three non-linefeed characters followed by a linefeed. That is we eat up the list of months from the end for each linefeed representing a month:
DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJANX20¶¶¶¶16
DECNOVOCTSEPAUGJULJUNMAYAPRMARFEBJAN¶¶¶16
DECNOVOCTSEPAUGJULJUNMAYAPRMARFEB¶¶16
DECNOVOCTSEPAUGJULJUNMAYAPRMAR¶16
DECNOVOCTSEPAUGJULJUNMAYAPR16
This is why we've inserted that X
: since the months start counting from 1
, we'll always remove at least three characters, even for January. Two of those characters are provided by the left over part from the year, but we need to insert that X
to get to three.
R-6`.
Finally, we remove everything up to the 6th character from the end. In other words we only keep the last five characters.