#include <iostream>
#include <cstring>
int main() {
const char *str_time = "20160907-05:00:54.123";
unsigned int year, month, day, hour, minute, second, miliseconds;
if (std::sscanf(str_time, "%4u%2u%2u-%2u:%2u:%2u.%3u",
&year, &month, &day, &hour, &minute, &second, &miliseconds) != 7)
{
std::cout << "Parse failed" << std::endl;
}
else
{
std::cout << year << month << day << "-" << hour << ":" << minute << ":"
<< second << "." << miliseconds << std::endl;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KIAppbnQgbWFpbigpIHsKICAgIGNvbnN0IGNoYXIgKnN0cl90aW1lID0gIjIwMTYwOTA3LTA1OjAwOjU0LjEyMyI7CiAgICB1bnNpZ25lZCBpbnQgeWVhciwgbW9udGgsIGRheSwgaG91ciwgbWludXRlLCBzZWNvbmQsIG1pbGlzZWNvbmRzOwogICAgCiAgICBpZiAoc3RkOjpzc2NhbmYoc3RyX3RpbWUsICIlNHUlMnUlMnUtJTJ1OiUydTolMnUuJTN1IiwgCiAgICAgICAgJnllYXIsICZtb250aCwgJmRheSwgJmhvdXIsICZtaW51dGUsICZzZWNvbmQsICZtaWxpc2Vjb25kcykgIT0gNykgCiAgICB7CiAgICAgCXN0ZDo6Y291dCA8PCAiUGFyc2UgZmFpbGVkIiA8PCBzdGQ6OmVuZGw7CiAgICB9IAogICAgZWxzZQogICAgewogICAgIAlzdGQ6OmNvdXQgPDwgeWVhciA8PCBtb250aCA8PCBkYXkgPDwgIi0iIDw8IGhvdXIgPDwgIjoiIDw8IG1pbnV0ZSA8PCAiOiIKICAgICAJICAgICAgICAgIDw8IHNlY29uZCA8PCAiLiIgPDwgbWlsaXNlY29uZHMgPDwgc3RkOjplbmRsOwogICAgfQp9