coligny 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.project +18 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +133 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/coligny.gemspec +25 -0
- data/lib/coligny/version.rb +3 -0
- data/lib/coligny.rb +327 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3295057f0fb4fced0262abd1d2f72676cdceb877
|
4
|
+
data.tar.gz: aba880f151f9c0526cb008ac13ea21498cf5d9de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e34fd03ca6baccf5b06b7ebeec7809d8f20e621bb14b03d4bd8c8ee36d0a518e42be340bc4cced3ed31f03fac994d3e27a562a86412ce01292c6e040f48ccd1
|
7
|
+
data.tar.gz: 8b7392dca2b263b5f735d32ce6f23121a25ab2fd720dd10f4b4a727a262027c03e08eb49e84bd7e9347c5c121911fbe4656348bb6a4cfd9e47040bca2d824b34
|
data/.gitignore
ADDED
data/.project
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<projectDescription>
|
3
|
+
<name>coligny</name>
|
4
|
+
<comment></comment>
|
5
|
+
<projects>
|
6
|
+
</projects>
|
7
|
+
<buildSpec>
|
8
|
+
<buildCommand>
|
9
|
+
<name>com.aptana.ide.core.unifiedBuilder</name>
|
10
|
+
<arguments>
|
11
|
+
</arguments>
|
12
|
+
</buildCommand>
|
13
|
+
</buildSpec>
|
14
|
+
<natures>
|
15
|
+
<nature>com.aptana.ruby.core.rubynature</nature>
|
16
|
+
<nature>com.aptana.projects.webnature</nature>
|
17
|
+
</natures>
|
18
|
+
</projectDescription>
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at shanekrusen@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Shane Krusen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
# Coligny
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/shanekrusen/coligny.svg?branch=master)](https://travis-ci.org/shanekrusen/coligny) [![Code Climate](https://codeclimate.com/github/shanekrusen/coligny/badges/gpa.svg)](https://codeclimate.com/github/shanekrusen/coligny)
|
4
|
+
|
5
|
+
Welcome!
|
6
|
+
Swáel!
|
7
|
+
|
8
|
+
This gem is intended to provide a resource for the use of the Coligny Calendar, according to its alignment by Helen McKay, in the Ruby Language.
|
9
|
+
|
10
|
+
##To-DO
|
11
|
+
|
12
|
+
- Finish long-term adjustments for slippage.
|
13
|
+
- Add Inscriptions for dates
|
14
|
+
- Comments
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'coligny'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install coligny
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
The main functionality of this project is the conversion of dates to and from the Coligny Calendar.
|
34
|
+
To convert a Gregorian date to Coligny:
|
35
|
+
|
36
|
+
Using the 30-year cycle of Saturn:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
example = Date.new(2016, 7, 24)
|
40
|
+
example_new = example.to_coligny_date
|
41
|
+
#=> #<ColignyDate:0x00000001a97f30>
|
42
|
+
```
|
43
|
+
|
44
|
+
Using the 19-year Metonic Cycle:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
example = Date.new(2016, 7, 24)
|
48
|
+
example_new = example.to_coligny_date(true)
|
49
|
+
#=> #<ColignyDate:0x00000001a97f30>
|
50
|
+
```
|
51
|
+
|
52
|
+
To convert to a Gregorian Date from a Coligny Date:
|
53
|
+
|
54
|
+
The method's arguments are the same as Ruby's Date object,
|
55
|
+
i.e. (year, month, day)
|
56
|
+
However, the Coligny Months **must** be passed as strings.
|
57
|
+
|
58
|
+
Using the 30-year Saturn cycle:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
example = Coligny::ColignyDate.new(3062, "Rivros", 10)
|
62
|
+
exmple_new = example.to_gregorian_date
|
63
|
+
#=> #<Date: 2043-07-24 ((2467455j,0s,0n),+0s,2299161j)>
|
64
|
+
```
|
65
|
+
|
66
|
+
Using the 19-year Metonic cycle:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
example = Coligny::ColignyDate.new(3062, "Rivros", 10, true)
|
70
|
+
exmple_new = example.to_gregorian_date
|
71
|
+
#=> #<Date: 2043-07-23 ((2467455j,0s,0n),+0s,2299161j)>
|
72
|
+
```
|
73
|
+
|
74
|
+
Attributes for dates in the Coligny calendar can be accessed:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
example = Coligny::ColignyDate.new(3062, "Rivros", 10)
|
78
|
+
example.year
|
79
|
+
#=> 3062
|
80
|
+
example.month.name
|
81
|
+
#=> "Rivros"
|
82
|
+
example.month.days
|
83
|
+
#=> 30
|
84
|
+
example.day
|
85
|
+
#=> 10
|
86
|
+
```
|
87
|
+
|
88
|
+
Days can be added to a Coligny Date to find the resulting date:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
example.calc_days(5)
|
92
|
+
```
|
93
|
+
or
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
example.calc_days(-5)
|
97
|
+
```
|
98
|
+
|
99
|
+
For the purpose of creating a calendar of the year, the ColignyYear class can be used.
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
example = Coligny::ColignyYear.new(2017)
|
103
|
+
#=> #<ColignyYear:0x000000018420f0>
|
104
|
+
```
|
105
|
+
|
106
|
+
A ColignyYear class has the attribute "months" which is an array of instances of the ColignyMonths class:
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
example.months
|
110
|
+
|
111
|
+
#=>[#<ColignyMonth:0x00000001599fb0 @name="Samonios", @days=30>,
|
112
|
+
#<ColignyMonth:0x00000001599f60 @name="Dumanios", @days=29>,
|
113
|
+
#<ColignyMonth:0x00000001599f10 @name="Rivros", @days=30>,
|
114
|
+
#<ColignyMonth:0x00000001599e70 @name="Anagantios", @days=29>,
|
115
|
+
#<ColignyMonth:0x00000001599da8 @name="Ogronios", @days=30>,
|
116
|
+
#<ColignyMonth:0x00000001599d58 @name="Cutios", @days=30>,
|
117
|
+
#<ColignyMonth:0x00000001599d08 @name="Giamonios", @days=29>,
|
118
|
+
#<ColignyMonth:0x00000001599cb8 @name="Simiuisonna", @days=30>,
|
119
|
+
#<ColignyMonth:0x00000001599b28 @name="Equos", @days=29>,
|
120
|
+
#<ColignyMonth:0x00000001599c68 @name="Elembi", @days=29>,
|
121
|
+
#<ColignyMonth:0x00000001599c18 @name="Aedrinni", @days=30>,
|
122
|
+
#<ColignyMonth:0x00000001599bc8 @name="Cantlos", @days=29>]
|
123
|
+
```
|
124
|
+
|
125
|
+
## License
|
126
|
+
|
127
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
128
|
+
|
129
|
+
## Credit
|
130
|
+
|
131
|
+
Developer - Shane Krusen
|
132
|
+
The model of the Coligny Calendar used for this project is the product of the work of the brilliant and lovely Helen McKay.
|
133
|
+
Support and feedback from the Modern Gaulish Community, Steve Hansen, Helen McKay, and my mentor, Klint Thrasher.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "coligny"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/coligny.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'coligny/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "coligny"
|
8
|
+
spec.version = Coligny::VERSION
|
9
|
+
spec.authors = ["Shane Krusen"]
|
10
|
+
spec.email = ["shanekrusen@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Implementation of Helen McKay's Coligny Calendar in Ruby'}
|
13
|
+
spec.description = %q{A collection of methods and classes required to construct calendars in, and convert Gregorian dates to, the Gaulish Calendar found in Coligny, France, according to Helen McKay's reconstruction.}
|
14
|
+
spec.homepage = "https://github.com/shanekrusen/coligny"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
25
|
+
end
|
data/lib/coligny.rb
ADDED
@@ -0,0 +1,327 @@
|
|
1
|
+
require "./lib/coligny/version"
|
2
|
+
|
3
|
+
module Coligny
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
def to_bg(ce)
|
7
|
+
return ce + 1019
|
8
|
+
end
|
9
|
+
|
10
|
+
module_function :to_bg
|
11
|
+
|
12
|
+
def to_ce(bg)
|
13
|
+
return bg - 1019
|
14
|
+
end
|
15
|
+
|
16
|
+
module_function :to_ce
|
17
|
+
|
18
|
+
class ColignyMonth
|
19
|
+
attr_reader :name
|
20
|
+
attr_accessor :days
|
21
|
+
|
22
|
+
def initialize(name, days)
|
23
|
+
@name = name
|
24
|
+
@days = days
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class ColignyYear
|
29
|
+
attr_accessor :months, :days
|
30
|
+
|
31
|
+
def initialize(year, is_metonic=false)
|
32
|
+
@is_metonic = is_metonic
|
33
|
+
@year = year
|
34
|
+
@working_year = Coligny.to_ce(@year)
|
35
|
+
@months = [ColignyMonth.new("Samonios", 30),
|
36
|
+
ColignyMonth.new("Dumanios", 29),
|
37
|
+
ColignyMonth.new("Rivros", 30),
|
38
|
+
ColignyMonth.new("Anagantios", 29),
|
39
|
+
ColignyMonth.new("Ogronios", 30),
|
40
|
+
ColignyMonth.new("Cutios", 30),
|
41
|
+
ColignyMonth.new("Giamonios", 29),
|
42
|
+
ColignyMonth.new("Simiuisonna", 30),
|
43
|
+
ColignyMonth.new("Elembi", 29),
|
44
|
+
ColignyMonth.new("Aedrinni", 30),
|
45
|
+
ColignyMonth.new("Cantlos", 29)]
|
46
|
+
|
47
|
+
if !is_metonic
|
48
|
+
populate_saturn_months
|
49
|
+
else
|
50
|
+
populate_metonic_months
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def is_early
|
57
|
+
if @is_metonic
|
58
|
+
return true if (@year < 3035)
|
59
|
+
return false
|
60
|
+
else
|
61
|
+
return true if (@year < 3034)
|
62
|
+
return false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def populate_saturn_earlier_equos
|
67
|
+
if ((2015 - @working_year) % 5 == 1) || ((2015 - @working_year) % 5 == 0)
|
68
|
+
@months.insert(8, ColignyMonth.new("Equos", 30))
|
69
|
+
else
|
70
|
+
@months.insert(8, ColignyMonth.new("Equos", 29))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def populate_saturn_earlier_int
|
75
|
+
if ((2015 - @working_year) % 5 == 0) && ((2015 - @working_year) % 30 != 5)
|
76
|
+
@months.unshift(ColignyMonth.new("Intercalary One", 29))
|
77
|
+
elsif ((2015 - @working_year) % 5 == 3)
|
78
|
+
@months.insert(6, ColignyMonth.new("Intercalary Two", 30))
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def populate_saturn_later_equos
|
83
|
+
if ((@working_year - 2015) % 5 == 0) || ((@working_year - 2015) % 5 == 4)
|
84
|
+
@months.insert(8, ColignyMonth.new("Equos", 30))
|
85
|
+
else
|
86
|
+
@months.insert(8, ColignyMonth.new("Equos", 29))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def populate_saturn_later_int
|
91
|
+
if ((@working_year - 2015) % 5 == 0)
|
92
|
+
@months.unshift(ColignyMonth.new("Intercalary One", 29))
|
93
|
+
elsif ((@working_year - 2015) % 5 == 2) && ((@working_year - 2015) % 30 != 27)
|
94
|
+
@months.insert(6, ColignyMonth.new("Intercalary Two", 30))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def populate_saturn_months
|
99
|
+
if (@year < 3034)
|
100
|
+
populate_saturn_earlier_equos
|
101
|
+
populate_saturn_earlier_int
|
102
|
+
else
|
103
|
+
populate_saturn_later_equos
|
104
|
+
populate_saturn_later_int
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_against_cases(cases)
|
109
|
+
cases.each do |test|
|
110
|
+
if ((@working_year - 2016) % 19) == test
|
111
|
+
return true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
return false
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_equos_days_metonic
|
118
|
+
cases = [3,4,8,9,13,14,18]
|
119
|
+
|
120
|
+
test_against_cases(cases)
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_intone_metonic
|
124
|
+
cases = [4,9,14]
|
125
|
+
|
126
|
+
test_against_cases(cases)
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_inttwo_metonic
|
130
|
+
cases = [1,6,11,16]
|
131
|
+
|
132
|
+
test_against_cases(cases)
|
133
|
+
end
|
134
|
+
|
135
|
+
def earlier_than_start_date_test_cases(cases)
|
136
|
+
cases.each do |test|
|
137
|
+
if ((2016 - @working_year) % 19) == test
|
138
|
+
return true
|
139
|
+
end
|
140
|
+
end
|
141
|
+
return false
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_earlier_than_start_equos_days_metonic
|
145
|
+
cases = [1,5,6,10,11,15,16]
|
146
|
+
|
147
|
+
earlier_than_start_date_test_cases(cases)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_earlier_than_start_date_intone_metonic
|
151
|
+
cases = [5,10,15]
|
152
|
+
|
153
|
+
earlier_than_start_date_test_cases(cases)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_earlier_than_start_date_inttwo_metonic
|
157
|
+
cases = [3,8,13,18]
|
158
|
+
|
159
|
+
earlier_than_start_date_test_cases(cases)
|
160
|
+
end
|
161
|
+
|
162
|
+
def populate_metonic_equos
|
163
|
+
if ((@year < 3035) && (test_earlier_than_start_equos_days_metonic)) || ((@year >= 3035) && (test_equos_days_metonic))
|
164
|
+
@months.insert(8, ColignyMonth.new("Equos", 30))
|
165
|
+
else
|
166
|
+
@months.insert(8, ColignyMonth.new("Equos", 29))
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def populate_metonic_int1
|
171
|
+
if (is_early && test_earlier_than_start_date_intone_metonic) || (!is_early && test_intone_metonic)
|
172
|
+
@months.unshift(ColignyMonth.new("Intercalary One", 29))
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def populate_metonic_int2
|
177
|
+
if (is_early && test_earlier_than_start_date_inttwo_metonic) || (!is_early && test_inttwo_metonic)
|
178
|
+
@months.insert(6, ColignyMonth.new("Intercalary Two", 30))
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def metonic_longcycle_int2_check
|
183
|
+
if ((@working_year - 2016) % 6569 <= 4) && ((@working_year - 2016) >= 6569) && (@months[6].name = "Intercalary Two")
|
184
|
+
@months.delete_at(6)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def metonic_longcycle_equos_check
|
189
|
+
if ((@working_year - 2016) % 61 <= 4) && ((@working_year - 2016) >= 61) && ((@working_year - 2016) % 5 == 4)
|
190
|
+
@months.find { |s| s.name == "Equos" }.days = 29
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def populate_metonic_months
|
195
|
+
populate_metonic_equos
|
196
|
+
populate_metonic_int1
|
197
|
+
populate_metonic_int2
|
198
|
+
|
199
|
+
if @year >= 3035
|
200
|
+
metonic_longcycle_int2_check
|
201
|
+
metonic_longcycle_equos_check
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
class ColignyDate
|
207
|
+
attr_accessor :year, :day, :month, :months
|
208
|
+
|
209
|
+
def initialize(year, month, day, is_metonic=false)
|
210
|
+
@is_metonic = is_metonic
|
211
|
+
@year = year
|
212
|
+
@day = day
|
213
|
+
if @is_metonic
|
214
|
+
@start_year = 3035
|
215
|
+
@start_date = Date.new(2016, 5, 14)
|
216
|
+
@months = ColignyYear.new(year, true).months
|
217
|
+
else
|
218
|
+
@start_year = 3034
|
219
|
+
@start_date = Date.new(2015, 4, 26)
|
220
|
+
@months = ColignyYear.new(year).months
|
221
|
+
end
|
222
|
+
@month = @months.find { |s| s.name == month }
|
223
|
+
end
|
224
|
+
|
225
|
+
def days_exceed_over
|
226
|
+
if @months[@months.index(@month) + 1].nil?
|
227
|
+
@day = @day - @month.days
|
228
|
+
@year += 1
|
229
|
+
if @is_metonic
|
230
|
+
@months = ColignyYear.new(@year, true).months
|
231
|
+
else
|
232
|
+
@months = ColignyYear.new(@year).months
|
233
|
+
end
|
234
|
+
@month = @months[0]
|
235
|
+
else
|
236
|
+
@day = @day - @month.days
|
237
|
+
@month = @months[@months.index(@month) + 1]
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def days_exceed_under
|
242
|
+
if @month == @months[0]
|
243
|
+
@year -= 1
|
244
|
+
if @is_metonic
|
245
|
+
@months = ColignyYear.new(@year, true).months
|
246
|
+
else
|
247
|
+
@months = ColignyYear.new(@year).months
|
248
|
+
end
|
249
|
+
@month = @months[-1]
|
250
|
+
@day = @month.days + (@day)
|
251
|
+
else
|
252
|
+
@month = @months[@months.index(@month) - 1]
|
253
|
+
@day = @month.days + (@day)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
def calc_days(add)
|
258
|
+
@day += add
|
259
|
+
|
260
|
+
while @day > @month.days
|
261
|
+
days_exceed_over
|
262
|
+
end
|
263
|
+
|
264
|
+
while @day < 1
|
265
|
+
days_exceed_under
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def earlier_check(check_date)
|
270
|
+
day_count = 0
|
271
|
+
|
272
|
+
until self.month.name == check_date.month.name && self.day == check_date.day && self.year == check_date.year
|
273
|
+
self.calc_days(1)
|
274
|
+
day_count += 1
|
275
|
+
end
|
276
|
+
|
277
|
+
return day_count
|
278
|
+
end
|
279
|
+
|
280
|
+
def later_check(check_date)
|
281
|
+
day_count = 0
|
282
|
+
|
283
|
+
until check_date.month.name == self.month.name && check_date.day == self.day && check_date.year == self.year
|
284
|
+
check_date.calc_days(1)
|
285
|
+
day_count += 1
|
286
|
+
end
|
287
|
+
|
288
|
+
return day_count
|
289
|
+
end
|
290
|
+
|
291
|
+
def to_gregorian_date
|
292
|
+
if @is_metonic
|
293
|
+
start = ColignyDate.new(3035, "Samonios", 1, true)
|
294
|
+
else
|
295
|
+
start = ColignyDate.new(3034, "Intercalary One", 1)
|
296
|
+
end
|
297
|
+
|
298
|
+
if (@year < @start_year)
|
299
|
+
return @start_date - earlier_check(start)
|
300
|
+
else
|
301
|
+
return @start_date + later_check(start)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
Date.class_eval do
|
307
|
+
def to_coligny_date(is_metonic=false)
|
308
|
+
if is_metonic
|
309
|
+
start = Date.new(2016, 5, 14)
|
310
|
+
end_date = Date.new(self.year, self.month, self.mday)
|
311
|
+
difference = (end_date - start).to_i
|
312
|
+
|
313
|
+
start_coligny = ColignyDate.new(3035, "Samonios", 1, true)
|
314
|
+
start_coligny.calc_days(difference)
|
315
|
+
return start_coligny
|
316
|
+
else
|
317
|
+
start = Date.new(2015, 4, 26)
|
318
|
+
end_date = Date.new(self.year, self.month, self.mday)
|
319
|
+
difference = (end_date - start).to_i
|
320
|
+
|
321
|
+
start_coligny = ColignyDate.new(3034, "Intercalary One", 1)
|
322
|
+
start_coligny.calc_days(difference)
|
323
|
+
return start_coligny
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coligny
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shane Krusen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: A collection of methods and classes required to construct calendars in,
|
56
|
+
and convert Gregorian dates to, the Gaulish Calendar found in Coligny, France, according
|
57
|
+
to Helen McKay's reconstruction.
|
58
|
+
email:
|
59
|
+
- shanekrusen@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".project"
|
66
|
+
- ".travis.yml"
|
67
|
+
- CODE_OF_CONDUCT.md
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- coligny.gemspec
|
75
|
+
- lib/coligny.rb
|
76
|
+
- lib/coligny/version.rb
|
77
|
+
homepage: https://github.com/shanekrusen/coligny
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.5.1
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Implementation of Helen McKay's Coligny Calendar in Ruby'
|
101
|
+
test_files: []
|