Skip to content
Snippets Groups Projects
Commit 70a9efc8 authored by xo30xoqa's avatar xo30xoqa
Browse files

Added AnnualDate functionality

parent 22a1c71d
No related branches found
No related tags found
No related merge requests found
...@@ -116,6 +116,11 @@ import Base./ # enable division with different length/area unit types ...@@ -116,6 +116,11 @@ import Base./ # enable division with different length/area unit types
/(x::S,y::T) where {S<:Area, T<:Area} = (upreferred(x)/) / (upreferred(y)/) /(x::S,y::T) where {S<:Area, T<:Area} = (upreferred(x)/) / (upreferred(y)/)
/(x::S,y::T) where {S<:Mass, T<:Mass} = (upreferred(x)/g) / (upreferred(y)/g) /(x::S,y::T) where {S<:Mass, T<:Mass} = (upreferred(x)/g) / (upreferred(y)/g)
## Utility type and function for working wth recurring dates
const AnnualDate = Tuple{Int64,Int64}
function thisyear(ad::AnnualDate, model::SimulationModel) = Date(year(model.date), ad...)
function nextyear(ad::AnnualDate, model::SimulationModel) = Date(year(model.date)+Year(1), ad...)
""" """
SimulationModel SimulationModel
......
...@@ -492,3 +492,22 @@ macro follow(leader, distance) ...@@ -492,3 +492,22 @@ macro follow(leader, distance)
:(followanimal!($(esc(:self)), $(esc(leader)), $(esc(:model)), $(esc(distance)))) :(followanimal!($(esc(:self)), $(esc(leader)), $(esc(:model)), $(esc(distance))))
end end
"""
@thisyear(annualdate)
Construct a date object referring to the current model year from an AnnualDate
(== Tuple{Int64,Int64}).
"""
macro thisyear(annualdate)
:(thisyear($(esc(annualdate)), $(esc(:model))))
end
"""
@nextyear(annualdate)
Construct a date object referring to the next year in the model from an AnnualDate
(== Tuple{Int64,Int64}).
"""
macro nextyear(annualdate)
:(nextyear($(esc(annualdate)), $(esc(:model))))
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment