easter 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/easter.rb +107 -0
- data.tar.gz.sig +2 -0
- metadata +68 -0
- metadata.gz.sig +2 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9ee41a6c486f484b5078c09b9b0003beb424ce6
|
4
|
+
data.tar.gz: f892fc072e1d7d7c3db9d33cd3974958c1b058af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 200c566dbb767b8cdacbb51f4512c945e7a443a5af077c074367f469406259c22a68441df45e45997ed8a4ed7f0b096d8ebfc710269060d8943d543d6c10757a
|
7
|
+
data.tar.gz: 3260576e1f71d7c96feb6e347229c838f396abf11bf1fdcb18cd285a00af0f865612b05475c56182fd7e007f827b9b8c4b4adce78d7b08f2961c017fc624d6c7
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/lib/easter.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: easter.rb
|
4
|
+
|
5
|
+
# ASP (rewritten in Ruby) Easter Calculation Library
|
6
|
+
#
|
7
|
+
# Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
|
8
|
+
#
|
9
|
+
# This work is licensed under the Creative Commons Attribution License. To view
|
10
|
+
# a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
|
11
|
+
# send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
|
12
|
+
# 94305, USA.
|
13
|
+
#
|
14
|
+
# This function library allows calculation of the following ecclesiastical holidays:
|
15
|
+
# Ash Wednesday, Palm Sunday, Good Friday, Easter, Ascension Day, and Pentecost.
|
16
|
+
#
|
17
|
+
# Refer to Wikipedia for information on the purpose of these holidays..
|
18
|
+
# Determine the date of Easter for a given year.
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
require 'date'
|
23
|
+
|
24
|
+
class Easter
|
25
|
+
|
26
|
+
def self.easter(some_year=Time.now.year)
|
27
|
+
|
28
|
+
golden_number = (some_year % 19) + 1
|
29
|
+
|
30
|
+
if some_year <= 1752 then
|
31
|
+
# Julian calendar
|
32
|
+
dominical_number = (some_year + (some_year / 4) + 5) % 7
|
33
|
+
paschal_full_moon = (3 - (11 * golden_number) - 7) % 30
|
34
|
+
else
|
35
|
+
# Gregorian calendar
|
36
|
+
dominical_number = (some_year + (some_year / 4) - (some_year / 100) + (some_year / 400)) % 7
|
37
|
+
solar_correction = (some_year - 1600) / 100 - (some_year - 1600) / 400
|
38
|
+
lunar_correction = (((some_year - 1400) / 100) * 8) / 25
|
39
|
+
paschal_full_moon = (3 - 11 * golden_number + solar_correction - lunar_correction) % 30
|
40
|
+
end
|
41
|
+
|
42
|
+
dominical_number += 7 until dominical_number > 0
|
43
|
+
|
44
|
+
paschal_full_moon += 30 until paschal_full_moon > 0
|
45
|
+
paschal_full_moon -= 1 if paschal_full_moon == 29 or (paschal_full_moon == 28 and golden_number > 11)
|
46
|
+
|
47
|
+
difference = (4 - paschal_full_moon - dominical_number) % 7
|
48
|
+
difference += 7 if difference < 0
|
49
|
+
|
50
|
+
day_easter = paschal_full_moon + difference + 1
|
51
|
+
|
52
|
+
if day_easter < 11 then
|
53
|
+
# Easter occurs in March.
|
54
|
+
return DateTime.new(y=some_year, m=3, d=day_easter + 21)
|
55
|
+
else
|
56
|
+
# Easter occurs in April.
|
57
|
+
return DateTime.new(y=some_year, m=4, d=day_easter - 10)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
# Determine the date of Good Friday for a given year.
|
63
|
+
#
|
64
|
+
def self.good_friday(some_year=Time.now.year)
|
65
|
+
easter(some_year) - 2
|
66
|
+
end
|
67
|
+
|
68
|
+
# Determine the date of Palm Sunday for a given year.
|
69
|
+
#
|
70
|
+
def self.palm_sunday(some_year=Time.now.year)
|
71
|
+
easter(some_year) - 7
|
72
|
+
end
|
73
|
+
|
74
|
+
# Determines the date of Ash Wednesday for a given year.
|
75
|
+
#
|
76
|
+
def self.ash_wednesday(some_year=Time.now.year)
|
77
|
+
easter(some_year) - 46
|
78
|
+
end
|
79
|
+
|
80
|
+
# Determines the date of Ascension Day for a given year.
|
81
|
+
#
|
82
|
+
def self.ascension_day(some_year=Time.now.year)
|
83
|
+
easter(some_year) - 39
|
84
|
+
end
|
85
|
+
|
86
|
+
# Determines the date of Pentecost for a given year.
|
87
|
+
#
|
88
|
+
def self.pentecost(some_year=Time.now.year)
|
89
|
+
easter(some_year) + 49
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
if $0 == __FILE__ then
|
95
|
+
|
96
|
+
test_year = 2014
|
97
|
+
out = []
|
98
|
+
out << "Ash Wednesday: ".ljust(15) + ash_wednesday(test_year).strftime("%D")
|
99
|
+
out << "Palm Sunday: ".ljust(15) + palm_sunday(test_year).strftime("%D")
|
100
|
+
out << "Good Friday: ".ljust(15) + good_friday(test_year).strftime("%D")
|
101
|
+
out << "Easter: ".ljust(15) + easter(test_year).strftime("%D")
|
102
|
+
out << "Ascension Day: ".ljust(15) + ascension_day(test_year).strftime("%D")
|
103
|
+
out << "Pentecost: ".ljust(15) + pentecost(test_year).strftime("%D")
|
104
|
+
|
105
|
+
puts out.join "\n"
|
106
|
+
|
107
|
+
end
|
data.tar.gz.sig
ADDED
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: easter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDljCCAn6gAwIBA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t
|
28
|
+
XTdfZk/MglIDLnPvIXpijDGwuhz1J8TmotMYXg6yBPdfFA19LealJQR9gjOgeFTw
|
29
|
+
TwT6i1fZA1R4l2gxfE4obgmv3sb6rIu8HlRjrL4KebbG/Dg90xeREdGT3wvnmXfv
|
30
|
+
AMz/uXv829Qndk96bw1w0caP5ztsDyB0k1e1ex3Uz1FJbxXj2VGl1+qdZS9zKF0I
|
31
|
+
9M/EBTpgF7h7vlimyfdgZFo5AOz9tFHP9bi2WCogLdk/Y5i1Qtat4ZQ1rm+OCvkM
|
32
|
+
3i1BPS/inz/40Q==
|
33
|
+
-----END CERTIFICATE-----
|
34
|
+
date: 2014-01-04 00:00:00.000000000 Z
|
35
|
+
dependencies: []
|
36
|
+
description: Returns the date for Easter, Ash Wednesday, Palm Sunday, Good Friday,
|
37
|
+
Ascension Day, and Pentecost.
|
38
|
+
email: james@r0bertson.co.uk
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- lib/easter.rb
|
44
|
+
homepage: https://github.com/jrobertson/easter
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.1.11
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: Calculates Easter day as well as related days
|
68
|
+
test_files: []
|
metadata.gz.sig
ADDED