Le campagne rispettano orario e giorni lavorativi, richiedono una mail di test con dati inseriti a mano prima dell'invio massivo e offrono una dashboard per monitorare l'avanzamento. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
878 B
Ruby
40 lines
878 B
Ruby
module Italy
|
|
class Holidays
|
|
FIXED = [
|
|
[1, 1],
|
|
[1, 6],
|
|
[4, 25],
|
|
[5, 1],
|
|
[6, 2],
|
|
[8, 15],
|
|
[11, 1],
|
|
[12, 8],
|
|
[12, 25],
|
|
[12, 26]
|
|
].freeze
|
|
|
|
def self.holiday?(date)
|
|
date = date.to_date
|
|
return true if FIXED.include?([date.month, date.day])
|
|
|
|
easter = easter_date(date.year)
|
|
date == easter || date == (easter + 1)
|
|
end
|
|
|
|
# Algoritmo gregoriano anonimo (Pasqua occidentale).
|
|
def self.easter_date(year)
|
|
a = year % 19
|
|
b, c = year.divmod(100)
|
|
d, e = b.divmod(4)
|
|
f = (b + 8) / 25
|
|
g = (b - f + 1) / 3
|
|
h = (19 * a + b - d - g + 15) % 30
|
|
i, k = c.divmod(4)
|
|
l = (32 + 2 * e + 2 * i - h - k) % 7
|
|
m = (a + 11 * h + 22 * l) / 451
|
|
month, day = (h + l - 7 * m + 114).divmod(31)
|
|
Date.new(year, month, day + 1)
|
|
end
|
|
end
|
|
end
|