Golfed
r i s d=$zcvt($zd($zdth(i_"01",8),6),"u") w $e(d,1,3)_$e(d,*-1,*)
Ungolfed
r i ; Read stdin and store into 'i' [200203]
s d= ; Set the variable 'd' to the following...
$zcvt( ; Convert the string
$zd( ; Parse the string as a caché date
$zdth( ; Convert the date to horolog format (# days from 12/31/1840)
i_"01", ; Append the string "01" to variable 'i' [20020301]
8 ; Use format #8 - "YYYYMMDD" (e.g. 20020301)
), [58864,0]
6 ; Use format #6 - "Mmm [D]D YYYY" (e.g. Mar 1 2002)
), [Mar 1 2002]
"u" ; Convert the string to uppercase
) [MAR 1 2002]
w ; Write out the following...
$e(d,1,3) ; Extract the substring from position 1 to 3 (inclusive) [MAR]
_ ; Concatenate
$e(d, ; Extract the substring...
*-1, ; ...from 1 character from the end of the string [0]
* ; ...to the last character [2]
) [02]
[MAR02]
Commentary
I don't think I've ever seen another Caché answer on this site. I'm only forced to know the language because of work (legacy code), but language itself is very powerful.
Some notes about the language:
- Caché doesn't really care about whitespace, so
r x r y
is the same as r x
\n
r y
- Each function is the shortname for the longer version:
r
== read
s
== set
$zcvt
== $zconvert
$zd
== $zdate
$zdth
== $zdateh
$e
== $extract
- Arrays are 1-indexed
Unfortunately, there is no online interpreter for Caché. Probably either because it's too obscure or maybe a licensing thing.
If you're interested in the language, you can check out their docs on their very 90's looking website :)