Commit a8d1eab6 authored by Michel Juillard's avatar Michel Juillard
Browse files

initial files

parents
name = "Periods"
uuid = "0c1d1a06-9168-427d-90e3-b4d73349562f"
authors = ["michel "]
version = "0.1.0"
module Periods
include("SimplePeriods.jl")
end # module
@enum Frequency Year Semester Quarter Month Week Business Day
struct SimplePeriod
ordinal::Int64
frequency::Frequency
end
function SimplePeriod(year, subperiod, frequency)
if frequency == Year
ordinal = year - 1970
elseif frequency == Semester
@assert(subperiod in 1:2)
ordinal = 2*(year - 1970) + subperiod - 1
elseif frequency == Quarter
@assert(subperiod in 1:4)
ordinal = 4*(year - 1970) + subperiod - 1
elseif frequency == Month
@assert(subperiod in 1:12)
ordinal = 12*(year - 1970) + subperiod - 1
elseif frequency == Week
ordinal = week1970(year, week)
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment