Skip to content

Instantly share code, notes, and snippets.

@igneus
Last active March 4, 2022 15:17
Show Gist options
  • Save igneus/71aa6ff0308c0de7a7d591a2e0f89163 to your computer and use it in GitHub Desktop.
Save igneus/71aa6ff0308c0de7a7d591a2e0f89163 to your computer and use it in GitHub Desktop.
Which date range(s) must sanctorale of each Liturgia horarum volume cover?
# Which date range(s) must sanctorale of each Liturgia horarum volume cover?
require 'calendarium-romanum/cr'
years = 1971 .. 3000
dates = CR::Temporale::Dates
xviii_sunday = lambda do |y|
dates.first_advent_sunday(y + 1) -
(1 + (34 - 18)) * 7
end
volume_ranges = {
# First Advent Sunday and Ash Wednesday cannot be suppressed by an occurring
# solemnity, so the first date relevant for sanctorale is the day after
1 => [
lambda {|y| dates.first_advent_sunday(y) + 1 },
dates.method(:baptism_of_lord)
],
2 => [
lambda {|y| dates.ash_wednesday(y) + 1 },
lambda {|y| dates.pentecost(y) - 1 }
],
# volume III covers two ranges of dates - before and after Lent+Eastertide
'3a' => [
dates.method(:baptism_of_lord),
lambda {|y| dates.ash_wednesday(y) - 1 }
],
'3b' => [
lambda {|y| dates.pentecost(y) + 1 },
lambda {|y| xviii_sunday.call(y) - 1 }
],
4 => [
xviii_sunday,
lambda {|y| dates.first_advent_sunday(y + 1) - 1 }
]
}
date_format = lambda {|date| date.month.to_s.rjust(2, '0') + '/' + date.day.to_s.rjust(2, '0') }
p years
puts
volume_ranges.each_pair do |number, (begin_proc, end_proc)|
begin_date =
years
.collect {|y| CR::AbstractDate.from_date begin_proc.call(y) }
.min
end_date =
years
.collect {|y| CR::AbstractDate.from_date end_proc.call(y) }
.max
puts "#{number}: #{date_format.call(begin_date)} .. #{date_format.call(end_date)}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment