PowerShell v2+, 49 46 bytes
PowerShell, 49 46 40 bytes
date "$args".insert(4,'-')-U %b%y|% *per
(date $args[0].insert(4,'-')-U %b%y).ToUpper()
Thanks to @Joey for saving 3 bytes!
Takes input $args[0]$args
as an explicit string (e.g., '201604'
) via command-line input. Uses the string.Insert()
function to put a -
in the appropriate space, and that resultant string forms input to the Get-Date
cmdlet with the -U
format parameter specifying the three-month shorthand plus two-digit year. We encapsulate that in parens, andthen tack on a .ToUpper()
to make the output string capitalized. That string is left on the pipeline and printing is implicit.
Also, as pointed out, this is locale-sensitive. Here's the locale information that I'm using where this works correctly.
PS C:\Tools\Scripts\golfing> get-culture
LCID Name DisplayName
---- ---- -----------
1033 en-US English (United States)
PS C:\Tools\Scripts\golfing> get-culture
LCID Name DisplayName
---- ---- -----------
1033 en-US English (United States)