when_easter 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # when\_easter
2
+
3
+ Ever wondered when will Easter (or Passover, if you prefer) be next year? No worries, use easter\_dates!_
4
+
5
+ ### Install
6
+ $ gem install when_easter
7
+
8
+ ### Use
9
+
10
+ $ when_easter
11
+ In the year 2010, the Roman Easter is on 24 April.
12
+ In the year 2010, the Greek Easter is on 24 April.
13
+
14
+ $ when_easter 2010
15
+ In the year 2010, the Roman Easter is on 04 April.
16
+ In the year 2010, the Greek Easter is on 04 April.
17
+
18
+ ### License
19
+
20
+ Released under the MIT license.
21
+ (c) 2011 Michał Nierebiński
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |gemspec|
6
+ gemspec.name= "when_easter"
7
+ gemspec.summary = "Get the date of Roman and Greek Easter"
8
+ gemspec.description = "A tool that calculates the dates of Roman and Greek Easter."
9
+ gemspec.email = "michal@nierebinski.pl"
10
+ gemspec.homepage = "https://github.com/Loyolny/when_easter"
11
+ gemspec.executables = ["when_easter"]
12
+ gemspec.authors = ["Michał Nierebiński"]
13
+ gemspec.date = File.utime(0,0,'VERSION')
14
+
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Ya don't have Jeweler gem installed. Install it with: sudo gem install jeweler"
19
+ end
20
+ #Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.1
data/bin/when_easter ADDED
@@ -0,0 +1,5 @@
1
+ #! /usr/bin/env ruby
2
+ require "rubygems"
3
+ require "when_easter"
4
+
5
+ puts WhenEaster.find(ARGV[0])
@@ -0,0 +1,59 @@
1
+ class WhenEaster
2
+ ## self.find
3
+ ##=> In the year 2010, the Roman Easter is on 24 April. \n In the year 2010, the Greek Easter is on 24 April.
4
+ def self.find(year = nil)
5
+ roman_date = self.roman_easter(year)
6
+ greek_date = self.greek_easter(year)
7
+ return "In the year #{roman_date.year}, the Roman easter is on #{roman_date.strftime("%d %B")}. \nIn the year #{greek_date.year}, the Roman easter is on #{greek_date.strftime("%d %B")}."
8
+ end
9
+
10
+ ## WhenEaster.roman_easter
11
+ ## => Sun Apr 24 00:00:00 +0200 2011
12
+ def self.roman_easter(year = nil)
13
+ year = Time.now.year if year.nil?
14
+ year = year.to_i if year.is_a?(String)
15
+ g = year % 19 +1
16
+ s = (year -1600) / 100 - (year-1600) / 400
17
+ l = (((year - 1400) / 100) * 8) / 25
18
+
19
+ p_2 = (3-11*g +s -l) % 30
20
+ if p_2 == 29 || (p_2 == 28 && g > 11)
21
+ p = p_2 -1
22
+ else
23
+ p= p_2
24
+ end
25
+
26
+ d= (year + year / 4 - year / 100 + year / 400) % 7
27
+ d_2 = (8-d) % 7
28
+
29
+ p_3 = (80 + p) % 7
30
+ x_2 = d_2 - p_3
31
+
32
+ x = (x_2 -1) % 7 +1
33
+ e = p+x
34
+
35
+ if e < 11
36
+ Time.local(year,3,e+21)
37
+ else
38
+ Time.local(year,4,e-10)
39
+ end
40
+ end
41
+
42
+ ## WhenEaster.greek_easter
43
+ ## => Sun Apr 24 00:00:00 +0200 2011
44
+ def self.greek_easter(year = nil)
45
+ year = Time.now.year if year.nil?
46
+ year = year.to_i if year.is_a?(String)
47
+ a = year % 19
48
+ b = year % 4
49
+ c = year % 7
50
+ d = (19 * a + 16) % 30
51
+ e = (2 * b + 4 * c + 6 * d) % 7;
52
+ easter = 3 + d + e;
53
+ if easter <= 30
54
+ Time.local(year, 4, easter)
55
+ else
56
+ Time.local(year, 5, (easter - 30))
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,41 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{when_easter}
8
+ s.version = "0.2.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Michał Nierebiński}]
12
+ s.date = %q{2011-06-28}
13
+ s.description = %q{A tool that calculates the dates of Roman and Greek Easter.}
14
+ s.email = %q{michal@nierebinski.pl}
15
+ s.executables = [%q{when_easter}]
16
+ s.extra_rdoc_files = [
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ "README.md",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "bin/when_easter",
24
+ "lib/when_easter.rb",
25
+ "when_easter.gemspec"
26
+ ]
27
+ s.homepage = %q{https://github.com/Loyolny/when_easter}
28
+ s.require_paths = [%q{lib}]
29
+ s.rubygems_version = %q{1.8.5}
30
+ s.summary = %q{Get the date of Roman and Greek Easter}
31
+
32
+ if s.respond_to? :specification_version then
33
+ s.specification_version = 3
34
+
35
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
36
+ else
37
+ end
38
+ else
39
+ end
40
+ end
41
+
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: when_easter
3
+ version: !ruby/object:Gem::Version
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 1
10
+ version: 0.2.1
11
+ platform: ruby
12
+ authors:
13
+ - "Micha\xC5\x82 Nierebi\xC5\x84ski"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-28 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: A tool that calculates the dates of Roman and Greek Easter.
22
+ email: michal@nierebinski.pl
23
+ executables:
24
+ - when_easter
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README.md
29
+ files:
30
+ - README.md
31
+ - Rakefile
32
+ - VERSION
33
+ - bin/when_easter
34
+ - lib/when_easter.rb
35
+ - when_easter.gemspec
36
+ homepage: https://github.com/Loyolny/when_easter
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.8.5
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Get the date of Roman and Greek Easter
69
+ test_files: []
70
+