hijri 0.0.1 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -1
- data/README.md +1 -1
- data/hijri.gemspec +0 -1
- data/lib/hijri/converter.rb +2 -2
- data/lib/hijri/version.rb +1 -1
- data/test/test_hijri.rb +6 -2
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a98ec623ad77ab2b54f166fdbcc38ef4eeb97f2
|
4
|
+
data.tar.gz: d052e589d43a0b18880b65e4c631d46ecccd4d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 720df8d0d28ebb2feb1236ecdf36a69a611eb8a9672bb1d4c79f8923dbcedc8433d034e9b32eef147b97168c70b9a1e268e9cfcded8fcd60f775ff56ce698da2
|
7
|
+
data.tar.gz: ba4885f4f7e184715c3b03fa90c20ce5a68b76895dbc1a10fd9666592ea017d63fec6ef5c1dc30a8593c945a825a2f4cef937d5999ebdabea735d9e2abbeddb8
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -30,7 +30,6 @@ Or install it yourself as:
|
|
30
30
|
hijri.to_greo
|
31
31
|
|
32
32
|
|
33
|
-
|
34
33
|
## TODO
|
35
34
|
|
36
35
|
- [ ] Add Hijri::Date and Hijri::DateTime.
|
@@ -38,6 +37,7 @@ Or install it yourself as:
|
|
38
37
|
- [ ] Add Hijri.now to create Hijri::DateTime object.
|
39
38
|
- [ ] Add Hijri.today to create Hijri::Date object.
|
40
39
|
- [ ] Implement strftime method.
|
40
|
+
- [ ] Add Comparable for Hijri::Date.
|
41
41
|
|
42
42
|
|
43
43
|
## Contributing
|
data/hijri.gemspec
CHANGED
data/lib/hijri/converter.rb
CHANGED
@@ -57,7 +57,7 @@ module Hijri
|
|
57
57
|
def absolute_to_greo(abs)
|
58
58
|
# Computes the Gregorian date from the absolute date.
|
59
59
|
# Search forward year by year from approximate year
|
60
|
-
year = (abs /
|
60
|
+
year = (abs / 366.0 + 0.5).to_i
|
61
61
|
while abs >= greo_to_absolute(year + 1, 1, 1)
|
62
62
|
year += 1
|
63
63
|
end
|
@@ -92,7 +92,7 @@ module Hijri
|
|
92
92
|
month += 1
|
93
93
|
end
|
94
94
|
|
95
|
-
day = abs - hijri_to_absolute(year, month, 1)
|
95
|
+
day = abs - hijri_to_absolute(year, month, 1) + 1
|
96
96
|
end
|
97
97
|
|
98
98
|
return [year, month, day]
|
data/lib/hijri/version.rb
CHANGED
data/test/test_hijri.rb
CHANGED
@@ -15,8 +15,12 @@ class TestHijri < MiniTest::Unit::TestCase
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_greo_date_to_hijri
|
18
|
-
date = Date.new
|
19
|
-
|
18
|
+
date = Date.new 2014, 12, 7
|
19
|
+
# switiching between solar calendar and lunar calendar is a bit
|
20
|
+
# hard and complecated and there is error ratio to it. Because
|
21
|
+
# of that we accept multiple date as a result.
|
22
|
+
correct_dates = (14..16).map {|n| "1436-02-#{n}" }
|
23
|
+
assert_includes correct_dates, date.to_hijri.to_s
|
20
24
|
end
|
21
25
|
|
22
26
|
def test_hijri_to_greo
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hijri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdulaziz AlShetwi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.8'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rubygems-tasks
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.2'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.2'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: yard
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|