coptic_date 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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTc2YjQwMjNlNjIzMjVkNTkxNjY2ODk1ZjE5MTgwYWUyMzYzN2QzNA==
5
+ data.tar.gz: !binary |-
6
+ N2MxOTBkYjU1OWVjZGY3OTI5MzNmMDRmZGE2ODkwNGM4MDEwNzRlMQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTFmNjY4Y2ZlYmI1YzhlMmQ4M2I3YjFiMDVmYThlNTVmNTFmYjAzNjdlOGFk
10
+ YzBkNzNhZmMwNDE4NjEyYTdiNTMyZWI5MzUxMmZjZGJlM2IyOGQ0ZGYyNjM3
11
+ YWUxYWYzNzAxN2NkMjQ3N2FhYmYyMmNiMGU0YWUzOGNmY2M0YWE=
12
+ data.tar.gz: !binary |-
13
+ OWQ3NzUyMzFjYTkzNzMyMGY1ODE3NmUwZjBjYTRjMjJmNmI2NDE4ZjdkZGFk
14
+ ZDVhYTZlZjVjNGVlYjM3ZjY5MzAxOGQ2NDVhMmNjYTM3ZDQ3NjNjNmZhOTll
15
+ NWVmMzgwZDgxMjhkYjliZmI0MTA3YWEzMjEwNDZmNmMzMjcyMDU=
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.project ADDED
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>coptic_date</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ </buildSpec>
9
+ <natures>
10
+ <nature>org.radrails.rails.core.railsnature</nature>
11
+ <nature>com.aptana.ruby.core.rubynature</nature>
12
+ </natures>
13
+ </projectDescription>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in coptic_date.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Kamal Micheal
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,44 @@
1
+ # CopticDate
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/coptic_date`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'coptic_date'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install coptic_date
22
+
23
+ ## Usage
24
+ ```
25
+ requested_date = Time.new(2015,9,8)
26
+ CopticDate::get_coptic_year(requested_date) #1731
27
+ CopticDate::get_coptic_month(requested_date) #13
28
+ CopticDate::get_coptic_day(requested_date) #3
29
+ ```
30
+ ## Development
31
+
32
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+
34
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing
37
+
38
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kimomicho/coptic_date.
39
+
40
+
41
+ ## License
42
+
43
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
44
+
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "coptic_date"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'coptic_date/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "coptic_date"
8
+ spec.version = CopticDate::VERSION
9
+ spec.authors = ["Kamal Micheal"]
10
+ spec.email = ["kimomicho@hotmail.com"]
11
+
12
+ spec.summary = "This gem is used to convert Gregorian calendar to Coptic calendar."
13
+ spec.homepage = "https://github.com/kimomicho/coptic_date_gem"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rspec'
24
+ end
@@ -0,0 +1,98 @@
1
+ # encoding: UTF-8
2
+ require "coptic_date/version"
3
+
4
+ module CopticDate
5
+ def self.calculate_remainder(greg_date)
6
+ # this may look wierd, however this is how calculations are made
7
+ greg_date_day = greg_date.day
8
+ greg_date_month = greg_date.month
9
+ greg_date_year = greg_date.year
10
+
11
+ if greg_date_month <= 2
12
+ intA = greg_date_month + 12
13
+ intB = greg_date_year - 1
14
+ else
15
+ intA = greg_date_month
16
+ intB = greg_date_year
17
+ end
18
+
19
+ intC = (intB / 100).to_i
20
+ intD = (intB / 400).to_i
21
+ intE = 2 - intC + intD
22
+ intF = ((intB + 4716) * 36525 / 100).to_i
23
+ intG = ((intA + 1) * 306001 / 10000).to_i
24
+ base_date = (greg_date_day + intG + intF + intE - 1826553)
25
+ c_year = base_date.div 365.25
26
+ #puts "base_date #{base_date}"
27
+ return ((base_date % 365.25) / 365.25) * 12.175
28
+ end
29
+
30
+ def self.get_coptic_year(greg_date)
31
+ if (greg_date.month < 9 || (greg_date.month == 9 && greg_date.day < 11))
32
+ return greg_date.year - 284
33
+ elsif (greg_date.month > 9 || (greg_date.month == 9 && greg_date.day > 11))
34
+ return greg_date.year - 283
35
+ else
36
+ #This means 11 September
37
+ #This needs calculations
38
+ c_year = greg_date.year - 284
39
+ if c_year % 4 == 3 && greg_date.year % 4 == 3
40
+ return c_year
41
+ else
42
+ return c_year + 1
43
+ end
44
+ end
45
+ end
46
+
47
+ def self.get_coptic_month(greg_date)
48
+ c_year = get_coptic_year(greg_date)
49
+ if c_year % 4 == 3 && greg_date.year % 4 == 3 && greg_date.month == 9 && greg_date.day == 11
50
+ return 13
51
+ else
52
+ calculate_remainder(greg_date).to_i + 1
53
+ end
54
+ end
55
+
56
+ def self.get_coptic_day(greg_date)
57
+ c_year = get_coptic_year(greg_date)
58
+ if c_year % 4 == 3 && greg_date.year % 4 == 3 && greg_date.month == 9 && greg_date.day == 11
59
+ return 6
60
+ else
61
+ remainder = calculate_remainder(greg_date)
62
+ #puts remainder
63
+ cday = (("0." + remainder.to_s.split(".")[1]).to_f * 30).round
64
+ cday < 1? 1 : cday
65
+ end
66
+ end
67
+
68
+ def self.get_coptic_month_name(month_number)
69
+ case coptic_month_number
70
+ when 1
71
+ "توت"
72
+ when 2
73
+ "بابه"
74
+ when 3
75
+ "هاتور"
76
+ when 4
77
+ "كيهك"
78
+ when 5
79
+ "طوبه"
80
+ when 6
81
+ "أمشير"
82
+ when 7
83
+ "برمهات"
84
+ when 8
85
+ "برموده"
86
+ when 9
87
+ "بشنس"
88
+ when 10
89
+ "بؤنة"
90
+ when 11
91
+ "أبيب"
92
+ when 12
93
+ "مسرى"
94
+ else
95
+ "النسئ"
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,3 @@
1
+ module CopticDate
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coptic_date
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kamal Micheal
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-15 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - kimomicho@hotmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .project
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - coptic_date.gemspec
71
+ - lib/coptic_date.rb
72
+ - lib/coptic_date/version.rb
73
+ homepage: https://github.com/kimomicho/coptic_date_gem
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.0.7
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: This gem is used to convert Gregorian calendar to Coptic calendar.
97
+ test_files: []