calendarium-romanum 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.rubocop.yml +9 -6
- data/.travis.yml +2 -1
- data/Appraisals +67 -0
- data/CHANGELOG.md +57 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +21 -12
- data/README.md +13 -10
- data/Rakefile +13 -2
- data/calendarium-romanum.gemspec +2 -2
- data/config/locales/pt.yml +94 -0
- data/data/czech-cs.txt +5 -2
- data/data/universal-1969-la.txt +1 -1
- data/data/universal-en.txt +5 -2
- data/data/universal-es.txt +7 -4
- data/data/universal-fr.txt +5 -2
- data/data/universal-it.txt +6 -3
- data/data/universal-la.txt +102 -99
- data/data/universal-pt.txt +248 -0
- data/lib/calendarium-romanum.rb +3 -0
- data/lib/calendarium-romanum/calendar.rb +13 -11
- data/lib/calendarium-romanum/cli.rb +32 -3
- data/lib/calendarium-romanum/cli/comparator.rb +22 -2
- data/lib/calendarium-romanum/data.rb +2 -0
- data/lib/calendarium-romanum/enum.rb +2 -4
- data/lib/calendarium-romanum/enums.rb +5 -1
- data/lib/calendarium-romanum/sanctorale.rb +51 -1
- data/lib/calendarium-romanum/sanctorale_factory.rb +2 -2
- data/lib/calendarium-romanum/sanctorale_writer.rb +6 -1
- data/lib/calendarium-romanum/temporale.rb +50 -21
- data/lib/calendarium-romanum/temporale/date_helper.rb +85 -0
- data/lib/calendarium-romanum/temporale/dates.rb +36 -111
- data/lib/calendarium-romanum/temporale/extensions/dedication_before_all_saints.rb +1 -1
- data/lib/calendarium-romanum/transfers.rb +29 -14
- data/lib/calendarium-romanum/version.rb +2 -2
- data/liturgical_law/2020_dubia_de_calendario_2022.md +100 -0
- metadata +15 -10
@@ -40,6 +40,7 @@ module CalendariumRomanum
|
|
40
40
|
GENERAL_ROMAN_ENGLISH = SanctoraleFile.new('universal-en.txt')
|
41
41
|
GENERAL_ROMAN_FRENCH = SanctoraleFile.new('universal-fr.txt')
|
42
42
|
GENERAL_ROMAN_ITALIAN = SanctoraleFile.new('universal-it.txt')
|
43
|
+
GENERAL_ROMAN_PORTUGUESE = SanctoraleFile.new('universal-pt.txt')
|
43
44
|
GENERAL_ROMAN_SPANISH = SanctoraleFile.new('universal-es.txt')
|
44
45
|
CZECH = SanctoraleFile.new('czech-cs.txt')
|
45
46
|
|
@@ -51,6 +52,7 @@ module CalendariumRomanum
|
|
51
52
|
GENERAL_ROMAN_ENGLISH,
|
52
53
|
GENERAL_ROMAN_FRENCH,
|
53
54
|
GENERAL_ROMAN_ITALIAN,
|
55
|
+
GENERAL_ROMAN_PORTUGUESE,
|
54
56
|
GENERAL_ROMAN_SPANISH,
|
55
57
|
CZECH,
|
56
58
|
] \
|
@@ -14,16 +14,14 @@ module CalendariumRomanum
|
|
14
14
|
def values(index_by: nil)
|
15
15
|
defined?(@indexed) && raise(RuntimeError.new('initialized repeatedly'))
|
16
16
|
|
17
|
-
@indexed = {}
|
18
17
|
@all = yield.freeze
|
18
|
+
@all.each &:freeze
|
19
19
|
|
20
|
+
@indexed = {}
|
20
21
|
@all.each_with_index do |val, i|
|
21
|
-
val.freeze
|
22
|
-
|
23
22
|
key = index_by ? val.public_send(index_by) : i
|
24
23
|
@indexed[key] = val
|
25
24
|
end
|
26
|
-
|
27
25
|
@indexed.freeze
|
28
26
|
end
|
29
27
|
|
@@ -154,9 +154,13 @@ module CalendariumRomanum
|
|
154
154
|
# Convenience module containing all the colour, season and rank constants
|
155
155
|
# for easy including
|
156
156
|
#
|
157
|
+
# Caveat: there is both a {Season} and a {Rank} with the identifier +TRIDUUM+.
|
158
|
+
# Due to this name clash, only the {Rank} is easily accessible
|
159
|
+
# using the {Constants} module.
|
160
|
+
#
|
157
161
|
# @example
|
158
162
|
# include CalendariumRomanum::Constants
|
159
|
-
# RED # now all the constants are available in current module
|
163
|
+
# RED # now all the constants are available in the current module
|
160
164
|
#
|
161
165
|
# @since 0.8.0
|
162
166
|
module Constants
|
@@ -22,6 +22,20 @@ module CalendariumRomanum
|
|
22
22
|
@metadata = nil
|
23
23
|
end
|
24
24
|
|
25
|
+
# @!method dup
|
26
|
+
# Returns a copy of the receiver with properly copied internal
|
27
|
+
# data structures, i.e. a copy which can be safely modified without
|
28
|
+
# danger of unintentionally modifying the original instance.
|
29
|
+
# @return [Sanctorale]
|
30
|
+
|
31
|
+
# @api private
|
32
|
+
def initialize_dup(other)
|
33
|
+
@days = other.days.dup
|
34
|
+
@solemnities = other.solemnities.dup
|
35
|
+
@symbols = other.symbols.dup
|
36
|
+
@metadata = Marshal.load Marshal.dump other.metadata # deep copy
|
37
|
+
end
|
38
|
+
|
25
39
|
# Content subset - only {Celebration}s in the rank(s) of solemnity.
|
26
40
|
#
|
27
41
|
# @return [Hash<AbstractDate=>Celebration>]
|
@@ -135,6 +149,15 @@ module CalendariumRomanum
|
|
135
149
|
rebuild_symbols
|
136
150
|
end
|
137
151
|
|
152
|
+
# Returns a new copy containing {Celebration}s from both self and +other+.
|
153
|
+
#
|
154
|
+
# @param other [Sanctorale]
|
155
|
+
# @return [Sanctorale]
|
156
|
+
# @since 0.9.0
|
157
|
+
def merge(other)
|
158
|
+
dup.tap {|dupped| dupped.update other }
|
159
|
+
end
|
160
|
+
|
138
161
|
# Retrieves {Celebration}s for the given date
|
139
162
|
#
|
140
163
|
# @param date [AbstractDate, Date]
|
@@ -206,9 +229,36 @@ module CalendariumRomanum
|
|
206
229
|
days == b.days
|
207
230
|
end
|
208
231
|
|
232
|
+
# Does this instance provide celebration identified by symbol +symbol+?
|
233
|
+
#
|
234
|
+
# @param symbol [Symbol]
|
235
|
+
# @return [Boolean]
|
236
|
+
# @since 0.9.0
|
237
|
+
def provides_celebration?(symbol)
|
238
|
+
@symbols.include? symbol
|
239
|
+
end
|
240
|
+
|
241
|
+
# If the instance contains a {Celebration} identified by the specified symbol,
|
242
|
+
# returns it's date and the {Celebration} itself, nil otherwise.
|
243
|
+
#
|
244
|
+
# @param symbol [Symbol]
|
245
|
+
# @return [Array<AbstractDate, Celebration>, nil]
|
246
|
+
# @since 0.9.0
|
247
|
+
def by_symbol(symbol)
|
248
|
+
return nil unless provides_celebration? symbol
|
249
|
+
|
250
|
+
@days.each_pair do |date, celebrations|
|
251
|
+
found = celebrations.find {|c| c.symbol == symbol }
|
252
|
+
return [date, found] if found
|
253
|
+
end
|
254
|
+
|
255
|
+
# reaching this point would mean that contents of @symbols and @days are not consistent
|
256
|
+
raise 'this point should never be reached'
|
257
|
+
end
|
258
|
+
|
209
259
|
protected
|
210
260
|
|
211
|
-
attr_reader :days
|
261
|
+
attr_reader :days, :symbols
|
212
262
|
|
213
263
|
# Builds the registry of celebration symbols anew,
|
214
264
|
# raises error if any duplicates are found.
|
@@ -42,8 +42,8 @@ module CalendariumRomanum
|
|
42
42
|
# include CalendariumRomanum
|
43
43
|
#
|
44
44
|
# my_sanctorale = SanctoraleFactory.load_layered_from_files(
|
45
|
-
# '
|
46
|
-
# '
|
45
|
+
# 'data/czech-cs.txt',
|
46
|
+
# 'data/czech-cechy-cs.txt'
|
47
47
|
# )
|
48
48
|
def load_layered_from_files(*paths)
|
49
49
|
loader = SanctoraleLoader.new
|
@@ -42,6 +42,11 @@ module CalendariumRomanum
|
|
42
42
|
Colours::RED => 'R'
|
43
43
|
}.freeze
|
44
44
|
|
45
|
+
# @param front_matter [Boolean] Should YAML front matter be written?
|
46
|
+
def initialize(front_matter: true)
|
47
|
+
@write_front_matter = front_matter
|
48
|
+
end
|
49
|
+
|
45
50
|
# Write to an object which understands +#<<+
|
46
51
|
#
|
47
52
|
# @param src [Sanctorale]
|
@@ -54,7 +59,7 @@ module CalendariumRomanum
|
|
54
59
|
dest ||= String.new
|
55
60
|
|
56
61
|
# Write metadata to YAML if present
|
57
|
-
unless src.metadata.nil? || src.metadata.empty?
|
62
|
+
unless (!@write_front_matter) || src.metadata.nil? || src.metadata.empty?
|
58
63
|
dest << src.metadata.to_yaml
|
59
64
|
dest << "---\n"
|
60
65
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
1
|
module CalendariumRomanum
|
4
2
|
|
5
3
|
# One of the two main {Calendar} components.
|
@@ -42,9 +40,8 @@ module CalendariumRomanum
|
|
42
40
|
# @return [Integer]
|
43
41
|
def liturgical_year(date)
|
44
42
|
year = date.year
|
45
|
-
temporale = Temporale.new year
|
46
43
|
|
47
|
-
if date <
|
44
|
+
if date < Dates.first_advent_sunday(year)
|
48
45
|
return year - 1
|
49
46
|
end
|
50
47
|
|
@@ -267,7 +264,7 @@ module CalendariumRomanum
|
|
267
264
|
good_friday
|
268
265
|
when Seasons::EASTER
|
269
266
|
easter_sunday + 1
|
270
|
-
when Seasons::ORDINARY
|
267
|
+
when Seasons::ORDINARY
|
271
268
|
baptism_of_lord + 1
|
272
269
|
else
|
273
270
|
raise ArgumentError.new('unsupported season')
|
@@ -309,7 +306,9 @@ module CalendariumRomanum
|
|
309
306
|
# @return [Celebration]
|
310
307
|
# @since 0.6.0
|
311
308
|
def [](date)
|
312
|
-
|
309
|
+
sw = season_and_week(date)
|
310
|
+
|
311
|
+
@solemnities[date] || @feasts[date] || sunday(date, sw) || @memorials[date] || ferial(date, sw)
|
313
312
|
end
|
314
313
|
|
315
314
|
# Retrieve temporale celebration for the given day
|
@@ -354,36 +353,57 @@ module CalendariumRomanum
|
|
354
353
|
Set.new(extensions) == Set.new(b.extensions)
|
355
354
|
end
|
356
355
|
|
356
|
+
# Does this instance provide celebration identified by symbol +symbol+?
|
357
|
+
#
|
358
|
+
# @param symbol [Symbol]
|
359
|
+
# @return [Boolean]
|
360
|
+
# @since 0.9.0
|
361
|
+
def provides_celebration?(symbol)
|
362
|
+
@all_celebration_symbols.include? symbol
|
363
|
+
end
|
364
|
+
|
357
365
|
protected
|
358
366
|
|
359
367
|
attr_reader :transfer_to_sunday, :extensions
|
360
368
|
|
361
369
|
private
|
362
370
|
|
371
|
+
SeasonWeek = Struct.new(:season, :week)
|
372
|
+
private_constant :SeasonWeek
|
373
|
+
|
374
|
+
def season_and_week(date)
|
375
|
+
s = season(date)
|
376
|
+
w = season_week(s, date)
|
377
|
+
|
378
|
+
SeasonWeek.new(s, w)
|
379
|
+
end
|
380
|
+
|
363
381
|
# seasons when Sundays have higher rank
|
364
382
|
SEASONS_SUNDAY_PRIMARY = [Seasons::ADVENT, Seasons::LENT, Seasons::EASTER].freeze
|
365
383
|
|
366
|
-
def sunday(date)
|
384
|
+
def sunday(date, season_week)
|
367
385
|
return nil unless date.sunday?
|
368
386
|
|
369
|
-
seas = season date
|
370
387
|
rank = Ranks::SUNDAY_UNPRIVILEGED
|
371
|
-
if SEASONS_SUNDAY_PRIMARY.include?(
|
388
|
+
if SEASONS_SUNDAY_PRIMARY.include?(season_week.season)
|
372
389
|
rank = Ranks::PRIMARY
|
373
390
|
end
|
374
391
|
|
375
|
-
week = Ordinalizer.ordinal season_week
|
376
|
-
title = I18n.t "temporale.#{
|
392
|
+
week = Ordinalizer.ordinal season_week.week
|
393
|
+
title = I18n.t "temporale.#{season_week.season.to_sym}.sunday", week: week
|
377
394
|
|
378
|
-
self.class.create_celebration title, rank,
|
395
|
+
self.class.create_celebration title, rank, season_week.season.colour, sunday: true
|
379
396
|
end
|
380
397
|
|
381
|
-
def ferial(date)
|
382
|
-
|
383
|
-
|
398
|
+
def ferial(date, season_week = nil)
|
399
|
+
# Normally +season_week+ is provided, but the method is once called also from Calendar
|
400
|
+
# and we definitely don't want Calendar to care that much about Temporale internals
|
401
|
+
# So as to know how to retrieve the value, so in that case we provide it ourselves.
|
402
|
+
season_week ||= season_and_week(date)
|
403
|
+
|
384
404
|
rank = Ranks::FERIAL
|
385
405
|
title = nil
|
386
|
-
case
|
406
|
+
case season_week.season
|
387
407
|
when Seasons::ADVENT
|
388
408
|
if date >= Date.new(@year, 12, 17)
|
389
409
|
rank = Ranks::FERIAL_PRIVILEGED
|
@@ -400,7 +420,7 @@ module CalendariumRomanum
|
|
400
420
|
title = I18n.t 'temporale.christmas.after_epiphany.ferial', weekday: I18n.t("weekday.#{date.wday}")
|
401
421
|
end
|
402
422
|
when Seasons::LENT
|
403
|
-
if week == 0
|
423
|
+
if season_week.week == 0
|
404
424
|
title = I18n.t 'temporale.lent.after_ashes.ferial', weekday: I18n.t("weekday.#{date.wday}")
|
405
425
|
elsif date > palm_sunday
|
406
426
|
rank = Ranks::PRIMARY
|
@@ -408,16 +428,16 @@ module CalendariumRomanum
|
|
408
428
|
end
|
409
429
|
rank = Ranks::FERIAL_PRIVILEGED unless rank > Ranks::FERIAL_PRIVILEGED
|
410
430
|
when Seasons::EASTER
|
411
|
-
if week == 1
|
431
|
+
if season_week.week == 1
|
412
432
|
rank = Ranks::PRIMARY
|
413
433
|
title = I18n.t 'temporale.easter.octave.ferial', weekday: I18n.t("weekday.#{date.wday}")
|
414
434
|
end
|
415
435
|
end
|
416
436
|
|
417
|
-
week_ord = Ordinalizer.ordinal week
|
418
|
-
title ||= I18n.t "temporale.#{
|
437
|
+
week_ord = Ordinalizer.ordinal season_week.week
|
438
|
+
title ||= I18n.t "temporale.#{season_week.season.to_sym}.ferial", week: week_ord, weekday: I18n.t("weekday.#{date.wday}")
|
419
439
|
|
420
|
-
self.class.create_celebration title, rank,
|
440
|
+
self.class.create_celebration title, rank, season_week.season.colour
|
421
441
|
end
|
422
442
|
|
423
443
|
# helper: difference between two Dates in days
|
@@ -445,6 +465,15 @@ module CalendariumRomanum
|
|
445
465
|
prepare_celebration_date date_proc, celebration
|
446
466
|
end
|
447
467
|
end
|
468
|
+
|
469
|
+
@all_celebration_symbols = Set.new(
|
470
|
+
@solemnities
|
471
|
+
.merge(@feasts)
|
472
|
+
.merge(@memorials)
|
473
|
+
.each_value
|
474
|
+
.collect(&:symbol)
|
475
|
+
.compact # all should have a symbol, but we really want to prevent nil here
|
476
|
+
)
|
448
477
|
end
|
449
478
|
|
450
479
|
def prepare_celebration_date(date_method, celebration)
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module CalendariumRomanum
|
2
|
+
class Temporale
|
3
|
+
# Provides utility methods for date arithmetics, available
|
4
|
+
# both as mixin instance methods and module methods.
|
5
|
+
#
|
6
|
+
# @since 0.9.0
|
7
|
+
module DateHelper
|
8
|
+
extend self
|
9
|
+
|
10
|
+
# @param weekday [Integer]
|
11
|
+
# @param date [Date]
|
12
|
+
# @return [Date]
|
13
|
+
def weekday_before(weekday, date)
|
14
|
+
if date.wday == weekday
|
15
|
+
date - WEEK
|
16
|
+
elsif weekday < date.wday
|
17
|
+
date - (date.wday - weekday)
|
18
|
+
else
|
19
|
+
date - (date.wday + WEEK - weekday)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# (see .weekday_before)
|
24
|
+
def weekday_after(weekday, date)
|
25
|
+
if date.wday == weekday
|
26
|
+
date + WEEK
|
27
|
+
elsif weekday > date.wday
|
28
|
+
date + (weekday - date.wday)
|
29
|
+
else
|
30
|
+
date + (WEEK - date.wday + weekday)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param date [Date]
|
35
|
+
# @return [Date]
|
36
|
+
def octave_of(date)
|
37
|
+
date + WEEK
|
38
|
+
end
|
39
|
+
|
40
|
+
# @!method sunday_before(date)
|
41
|
+
# @param date [Date]
|
42
|
+
# @return [Date]
|
43
|
+
# @!method monday_before(date)
|
44
|
+
# (see .sunday_before)
|
45
|
+
# @!method tuesday_before(date)
|
46
|
+
# (see .sunday_before)
|
47
|
+
# @!method wednesday_before(date)
|
48
|
+
# (see .sunday_before)
|
49
|
+
# @!method thursday_before(date)
|
50
|
+
# (see .sunday_before)
|
51
|
+
# @!method friday_before(date)
|
52
|
+
# (see .sunday_before)
|
53
|
+
# @!method saturday_before(date)
|
54
|
+
# (see .sunday_before)
|
55
|
+
|
56
|
+
# @!method sunday_after(date)
|
57
|
+
# @param date [Date]
|
58
|
+
# @return [Date]
|
59
|
+
# @!method monday_after(date)
|
60
|
+
# (see .sunday_after)
|
61
|
+
# @!method tuesday_after(date)
|
62
|
+
# (see .sunday_after)
|
63
|
+
# @!method wednesday_after(date)
|
64
|
+
# (see .sunday_after)
|
65
|
+
# @!method thursday_after(date)
|
66
|
+
# (see .sunday_after)
|
67
|
+
# @!method friday_after(date)
|
68
|
+
# (see .sunday_after)
|
69
|
+
# @!method saturday_after(date)
|
70
|
+
# (see .sunday_after)
|
71
|
+
|
72
|
+
# @api private
|
73
|
+
WEEKDAYS = %w(sunday monday tuesday wednesday thursday friday saturday).freeze
|
74
|
+
WEEKDAYS.each_with_index do |weekday, weekday_i|
|
75
|
+
define_method "#{weekday}_before" do |date|
|
76
|
+
send('weekday_before', weekday_i, date)
|
77
|
+
end
|
78
|
+
|
79
|
+
define_method "#{weekday}_after" do |date|
|
80
|
+
send('weekday_after', weekday_i, date)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -3,19 +3,22 @@ module CalendariumRomanum
|
|
3
3
|
# Provides methods computing dates of movable feasts
|
4
4
|
# and utilities for common computations of relative dates
|
5
5
|
module Dates
|
6
|
-
|
7
|
-
|
6
|
+
include DateHelper
|
7
|
+
extend self
|
8
|
+
|
9
|
+
# (see #nativity)
|
10
|
+
def first_advent_sunday(year)
|
8
11
|
sunday_before(nativity(year)) - 3 * WEEK
|
9
12
|
end
|
10
13
|
|
11
14
|
# @param year [Integer] liturgical year
|
12
15
|
# @return [Date]
|
13
|
-
def
|
16
|
+
def nativity(year)
|
14
17
|
Date.new(year, 12, 25)
|
15
18
|
end
|
16
19
|
|
17
|
-
# (see
|
18
|
-
def
|
20
|
+
# (see #nativity)
|
21
|
+
def holy_family(year)
|
19
22
|
xmas = nativity(year)
|
20
23
|
if xmas.sunday?
|
21
24
|
return Date.new(year, 12, 30)
|
@@ -24,15 +27,15 @@ module CalendariumRomanum
|
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
|
-
# (see
|
28
|
-
def
|
30
|
+
# (see #nativity)
|
31
|
+
def mother_of_god(year)
|
29
32
|
octave_of(nativity(year))
|
30
33
|
end
|
31
34
|
|
32
35
|
# @param year [Integer] liturgical year
|
33
36
|
# @param sunday [Boolean] transfer to Sunday?
|
34
37
|
# @return [Date]
|
35
|
-
def
|
38
|
+
def epiphany(year, sunday: false)
|
36
39
|
if sunday
|
37
40
|
# GNLYC 7 a)
|
38
41
|
return sunday_after(Date.new(year + 1, 1, 1))
|
@@ -44,7 +47,7 @@ module CalendariumRomanum
|
|
44
47
|
# @param year [Integer] liturgical year
|
45
48
|
# @param epiphany_on_sunday [Boolean] was Epiphany transferred to Sunday?
|
46
49
|
# @return [Date]
|
47
|
-
def
|
50
|
+
def baptism_of_lord(year, epiphany_on_sunday: false)
|
48
51
|
e = epiphany(year, sunday: epiphany_on_sunday)
|
49
52
|
if e.day > 6
|
50
53
|
e + 1
|
@@ -53,13 +56,13 @@ module CalendariumRomanum
|
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
56
|
-
# (see
|
57
|
-
def
|
59
|
+
# (see #nativity)
|
60
|
+
def ash_wednesday(year)
|
58
61
|
easter_sunday(year) - (6 * WEEK + 4)
|
59
62
|
end
|
60
63
|
|
61
|
-
# (see
|
62
|
-
def
|
64
|
+
# (see #nativity)
|
65
|
+
def easter_sunday(year)
|
63
66
|
year += 1
|
64
67
|
|
65
68
|
# algorithm below taken from the 'easter' gem:
|
@@ -85,23 +88,23 @@ module CalendariumRomanum
|
|
85
88
|
end
|
86
89
|
end
|
87
90
|
|
88
|
-
# (see
|
89
|
-
def
|
91
|
+
# (see #nativity)
|
92
|
+
def palm_sunday(year)
|
90
93
|
easter_sunday(year) - 7
|
91
94
|
end
|
92
95
|
|
93
|
-
# (see
|
94
|
-
def
|
96
|
+
# (see #nativity)
|
97
|
+
def good_friday(year)
|
95
98
|
easter_sunday(year) - 2
|
96
99
|
end
|
97
100
|
|
98
|
-
# (see
|
99
|
-
def
|
101
|
+
# (see #nativity)
|
102
|
+
def holy_saturday(year)
|
100
103
|
easter_sunday(year) - 1
|
101
104
|
end
|
102
105
|
|
103
106
|
# (see .epiphany)
|
104
|
-
def
|
107
|
+
def ascension(year, sunday: false)
|
105
108
|
if sunday
|
106
109
|
# GNLYC 7 b)
|
107
110
|
return easter_sunday(year) + 6 * WEEK
|
@@ -110,18 +113,18 @@ module CalendariumRomanum
|
|
110
113
|
pentecost(year) - 10
|
111
114
|
end
|
112
115
|
|
113
|
-
# (see
|
114
|
-
def
|
116
|
+
# (see #nativity)
|
117
|
+
def pentecost(year)
|
115
118
|
easter_sunday(year) + 7 * WEEK
|
116
119
|
end
|
117
120
|
|
118
|
-
# (see
|
119
|
-
def
|
121
|
+
# (see #nativity)
|
122
|
+
def holy_trinity(year)
|
120
123
|
octave_of(pentecost(year))
|
121
124
|
end
|
122
125
|
|
123
126
|
# (see .epiphany)
|
124
|
-
def
|
127
|
+
def corpus_christi(year, sunday: false)
|
125
128
|
if sunday
|
126
129
|
# GNLYC 7 c)
|
127
130
|
return holy_trinity(year) + WEEK
|
@@ -130,103 +133,25 @@ module CalendariumRomanum
|
|
130
133
|
holy_trinity(year) + 4
|
131
134
|
end
|
132
135
|
|
133
|
-
# (see
|
134
|
-
def
|
136
|
+
# (see #nativity)
|
137
|
+
def sacred_heart(year)
|
135
138
|
corpus_christi(year) + 8
|
136
139
|
end
|
137
140
|
|
138
|
-
# (see
|
139
|
-
def
|
141
|
+
# (see #nativity)
|
142
|
+
def mother_of_church(year)
|
140
143
|
pentecost(year) + 1
|
141
144
|
end
|
142
145
|
|
143
|
-
# (see
|
144
|
-
def
|
146
|
+
# (see #nativity)
|
147
|
+
def immaculate_heart(year)
|
145
148
|
pentecost(year) + 20
|
146
149
|
end
|
147
150
|
|
148
|
-
# (see
|
149
|
-
def
|
151
|
+
# (see #nativity)
|
152
|
+
def christ_king(year)
|
150
153
|
first_advent_sunday(year + 1) - 7
|
151
154
|
end
|
152
|
-
|
153
|
-
# utility methods
|
154
|
-
|
155
|
-
# @param weekday [Integer]
|
156
|
-
# @param date [Date]
|
157
|
-
# @return [Date]
|
158
|
-
def self.weekday_before(weekday, date)
|
159
|
-
if date.wday == weekday
|
160
|
-
date - WEEK
|
161
|
-
elsif weekday < date.wday
|
162
|
-
date - (date.wday - weekday)
|
163
|
-
else
|
164
|
-
date - (date.wday + WEEK - weekday)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
# (see .weekday_before)
|
169
|
-
def self.weekday_after(weekday, date)
|
170
|
-
if date.wday == weekday
|
171
|
-
date + WEEK
|
172
|
-
elsif weekday > date.wday
|
173
|
-
date + (weekday - date.wday)
|
174
|
-
else
|
175
|
-
date + (WEEK - date.wday + weekday)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
# @param date [Date]
|
180
|
-
# @return [Date]
|
181
|
-
def self.octave_of(date)
|
182
|
-
date + WEEK
|
183
|
-
end
|
184
|
-
|
185
|
-
class << self
|
186
|
-
# @!method sunday_before(date)
|
187
|
-
# @param date [Date]
|
188
|
-
# @return [Date]
|
189
|
-
# @!method monday_before(date)
|
190
|
-
# (see .sunday_before)
|
191
|
-
# @!method tuesday_before(date)
|
192
|
-
# (see .sunday_before)
|
193
|
-
# @!method wednesday_before(date)
|
194
|
-
# (see .sunday_before)
|
195
|
-
# @!method thursday_before(date)
|
196
|
-
# (see .sunday_before)
|
197
|
-
# @!method friday_before(date)
|
198
|
-
# (see .sunday_before)
|
199
|
-
# @!method saturday_before(date)
|
200
|
-
# (see .sunday_before)
|
201
|
-
|
202
|
-
# @!method sunday_after(date)
|
203
|
-
# @param date [Date]
|
204
|
-
# @return [Date]
|
205
|
-
# @!method monday_after(date)
|
206
|
-
# (see .sunday_after)
|
207
|
-
# @!method tuesday_after(date)
|
208
|
-
# (see .sunday_after)
|
209
|
-
# @!method wednesday_after(date)
|
210
|
-
# (see .sunday_after)
|
211
|
-
# @!method thursday_after(date)
|
212
|
-
# (see .sunday_after)
|
213
|
-
# @!method friday_after(date)
|
214
|
-
# (see .sunday_after)
|
215
|
-
# @!method saturday_after(date)
|
216
|
-
# (see .sunday_after)
|
217
|
-
|
218
|
-
# @api private
|
219
|
-
WEEKDAYS = %w(sunday monday tuesday wednesday thursday friday saturday).freeze
|
220
|
-
WEEKDAYS.each_with_index do |weekday, weekday_i|
|
221
|
-
define_method "#{weekday}_before" do |date|
|
222
|
-
send('weekday_before', weekday_i, date)
|
223
|
-
end
|
224
|
-
|
225
|
-
define_method "#{weekday}_after" do |date|
|
226
|
-
send('weekday_after', weekday_i, date)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
155
|
end
|
231
156
|
end
|
232
157
|
end
|