Holidays v0.2.4 Holidays.DateCalculator.DateMath View Source
Link to this section Summary
Functions
Adds the given number of days
to the given date
.
Returns a list of tuples with week and day atoms.
Returns the date for the week
th weekday
for the given year
and month
.
Link to this section Functions
Link to this function
add_days(date, days)
View Sourceadd_days(:calendar.date(), integer()) :: :calendar.date()
Adds the given number of days
to the given date
.
Examples
iex> Holidays.DateCalculator.DateMath.add_days({2015, 12, 31}, 1)
{2016, 1, 1}
iex> Holidays.DateCalculator.DateMath.add_days({2016, 1, 6}, -12)
{2015, 12, 25}
Link to this function
get_week_and_weekday(date)
View Sourceget_week_and_weekday(:calendar.date()) :: [ {Holidays.week(), Holidays.weekday()} ]
Returns a list of tuples with week and day atoms.
The list will contain a single item except when the day is both the :fourth
and the :last
week.
Examples
iex> Holidays.DateCalculator.DateMath.get_week_and_weekday({2016,1,29})
[{:last, :friday}]
iex> Holidays.DateCalculator.DateMath.get_week_and_weekday({2016,1,25})
[{:fourth, :monday}, {:last, :monday}]
iex> Holidays.DateCalculator.DateMath.get_week_and_weekday({2016,1,5})
[{:first, :tuesday}]
Link to this function
get_weekth_day(year, month, week, weekday)
View Sourceget_weekth_day( pos_integer(), pos_integer(), Holidays.week(), Holidays.weekday() | pos_integer() ) :: :calendar.date()
Returns the date for the week
th weekday
for the given year
and month
.
week
may be one of :first, :second, :third, :fourth, :last
weekday
may be a number between 1 and 7, which is the way Erlang
represents Monday through Sunday. Or use one the atoms
:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday
Examples
# The second Tuesday of June, 2013
iex> Holidays.DateCalculator.DateMath.get_weekth_day(2013, 6, :second, :tuesday)
{2013, 6, 11}
# The third Friday of December, 2013
iex> Holidays.DateCalculator.DateMath.get_weekth_day(2013, 12, :third, :friday)
{2013, 12, 20}
# The last Saturday of January, 2013
iex> Holidays.DateCalculator.DateMath.get_weekth_day(2013, 1, :last, :saturday)
{2013, 1, 26}