Skip to content

Convert string to MIT #81

@Nic2020

Description

@Nic2020

I would be great to have a function to convert a string to an MIT of the correct frequency.

For instance:

frequencymap = Dict{Char,Any}(
    'Q' => Quarterly,
    'M' => Monthly,
    'Y' => Yearly,
)
convert_string_to_mit(t::AbstractString) = length(t) > 5 ? MIT{frequencymap[t[5]]}(parse(Int, t[1:4]), parse(Int, t[6:end])) : MIT{Yearly}(parse(Int, t[1:4]))
convert_string_to_mit("2022")
convert_string_to_mit("2022M11")
convert_string_to_mit("2022Q3")

We could also use Julia's syntax: convert(MIT{Monthly},"2022M1")

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions