Perl 6, 111 89 87 bytes
{~DateTime.new($_/Ⅿ,:formatter{"{(.year%Ⅽ,.month,.day).fmt('%02d','')}.{(.hour,.minute).fmt('%02d','')}"})}
Try it (111)
{TR/-//}o{S/..//}o{.yyyy-mm-dd~'.'~(.hour,.minute).fmt('%02d','')}o{DateTime.new($_/Ⅿ)}
Try it (89)
{TR/- //}o{S/..//}o{.yyyy-mm-dd~'.'~(.hour,.minute).fmt('%02d')}o{DateTime.new($_/Ⅿ)}
Try it (87)
Explanation:
The o
infix operator takes two functions and creates a composite function. The rightmost one gets called first, and the one to the left gets called with its result.
Basically we use 4 block lambdas to generate a single lambda.
Which is not much different to how a WhateverCode lambda like * + *
gets created.
Divide by 1000 and use that to create a DateTime object.
{DateTime.new($_/Ⅿ)} # Ⅿ is ROMAN NUMERAL ONE THOUSAND (3 bytes)
The result gets used by:
{
.yyyy-mm-dd # 2019-01-11
~ '.' ~ # str concatenation with '.'
( .hour, .minute ).fmt('%02d') # add leading 0s (returns List)
}
That leaves us with a string like 2019-01-11.19 11
We need to remove the first two digits
{S/..//}
We also need to remove -
and
{TR/- //}