Module: Holidays::Definition::CustomMethods::CN
- Defined in:
- lib/holidays/definition/custom_methods/cn.rb
Overview
cn custom holiday calculations, ported verbatim from the
methods: block in definitions/cn.yaml.
Class Method Summary collapse
-
.cn_qingming(year) ⇒ Object
Qingming falls when the sun reaches celestial longitude 15 degrees, which lands on 4 or 5 April.
Class Method Details
.cn_qingming(year) ⇒ Object
Qingming falls when the sun reaches celestial longitude 15 degrees, which lands on 4 or 5 April. This is the standard solar-term approximation; the century constant shifts between the 20th and 21st centuries.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/holidays/definition/custom_methods/cn.rb', line 14 def cn_qingming(year) constant = case year when 1900..1999 5.59 when 2000..2099 4.81 else raise IndexError.new("Out of range") end y = year % 100 Date.civil(year, 4, (y * 0.2422 + constant).floor - (y / 4)) end |