Skip to content
Snippets Groups Projects

Calendar features (sans vacances scolaires)

Merged Rakotosoa Toavina Michel requested to merge calendar-features into main
6 files
+ 220
8
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 67
0
defmodule Analyzer.Predictor.Calendar.DayOffs do
@moduledoc """
Jour de fêtes
"""
def all_saints(date) do
Date.new!(date.year, 11, 1)
end
def workers_day(date) do
Date.new!(date.year, 5, 1)
end
def christmas(date) do
Date.new!(date.year, 12, 25)
end
def easter(year) do
a = Integer.mod(year, 19)
b = Integer.floor_div(year, 100)
c = Integer.mod(year, 100)
d = Integer.floor_div(b, 4)
e = Integer.mod(b, 4)
tmp1 = 8 * b + 13
g = Integer.floor_div(tmp1, 25)
tmp2 = 19 * a + b - d - g + 15
h = Integer.mod(tmp2, 30)
j = Integer.floor_div(c, 4)
k = Integer.mod(c, 4)
tmp3 = a + 11 * h
m = Integer.floor_div(tmp3, 319)
tmp4 = 2 * e + 2 * j - k - h + m + 32
r = Integer.mod(tmp4, 7)
tmp5 = h - m + r + 90
n = Integer.floor_div(tmp5, 25)
tmp6 = h - m + r + n + 19
p = Integer.mod(tmp6, 32)
Date.new!(year, n, p)
end
def easter_monday(easter) do
Date.add(easter, 1)
end
def ascension(easter) do
Date.add(easter, 39)
end
def pentecost(easter) do
Date.add(easter, 49)
end
def pentecost_monday(easter) do
Date.add(easter, 50)
end
def independance_day(date) do
Date.new!(date.year, 6, 26)
end
end