Storing and parsing Dates.CompoundPeriod?

OK.
One option without regexp:

using Dates

# CompoundPeriod
cp1 = Hour(25) + Second(62) + Microsecond(10)
str1 = string(cp1)

# Parse string
x = split.(split(str1, ','))
v1 = first.(x)
s1 = chop.(uppercasefirst.(last.(x)))
cp2 = sum([eval(Meta.parse("$s($v)")) for (v,s) in zip(v1,s1)])

cp2 == cp1      # true
1 Like