parsi-date 0.4.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +6 -7
- data/README.md +94 -0
- data/lib/parsi-date.rb +32 -28
- data/lib/version.rb +1 -1
- data/parsi-date.gemspec +1 -0
- data/spec/parsi-date/accessor_spec.rb +23 -14
- data/spec/parsi-date/accessors_helper_spec.rb +1 -0
- data/spec/parsi-date/add_month_spec.rb +4 -2
- data/spec/parsi-date/add_spec.rb +4 -2
- data/spec/parsi-date/comp_spec.rb +9 -9
- data/spec/parsi-date/constants_spec.rb +14 -10
- data/spec/parsi-date/construction_spec.rb +11 -10
- data/spec/parsi-date/conversion_spec.rb +18 -7
- data/spec/parsi-date/leap_spec.rb +8 -8
- data/spec/parsi-date/step_spec.rb +14 -14
- data/spec/parsi-date/strftime_spec.rb +40 -40
- data/spec/parsi-date/week_methods_spec.rb +8 -8
- metadata +18 -4
- data/README.rdoc +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ba469a494b1e1aae0d7c2c7f588da147cc467248ddbe734f435e3fab64d4171
|
4
|
+
data.tar.gz: 56e054bb3539f9e52ceb0ed6f766d9b058ee2a0457b61ba78593e5ce12232193
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2584be47bf36f9946259cf0e8d8954c4ab9132ae05986509f70655fc57900f9e5bbb43eefc0186a93992a0a1990c9fb99b8f06639558f78f3e88c9ed1330bbc9
|
7
|
+
data.tar.gz: dc6fc42431960c45147036b6dc86ae3097ac9dbfb27e5d96be312d5048c71f3d6b3ebd26c41501d1f028bb56075b853e2646adb638338716fc3f9aa35aabc6bf
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [master]
|
6
|
-
pull_request:
|
7
|
-
branches: [master]
|
3
|
+
on: [push, pull_request]
|
8
4
|
|
9
5
|
permissions:
|
10
6
|
contents: read
|
@@ -14,10 +10,13 @@ jobs:
|
|
14
10
|
runs-on: ubuntu-latest
|
15
11
|
strategy:
|
16
12
|
matrix:
|
17
|
-
ruby-version:
|
13
|
+
ruby-version:
|
14
|
+
- '3.1'
|
15
|
+
- '3.2'
|
16
|
+
- '3.3'
|
18
17
|
|
19
18
|
steps:
|
20
|
-
- uses: actions/checkout@
|
19
|
+
- uses: actions/checkout@v4
|
21
20
|
- name: Set up Ruby
|
22
21
|
uses: ruby/setup-ruby@v1
|
23
22
|
with:
|
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Parsi Date
|
2
|
+
|
3
|
+
The Parsi Date library is an implementation of the [Solar Hijri Calendar](http://en.wikipedia.org/wiki/Solar_Hijri_calendar), also known as the Jalali or Persian Calendar, which is the official calendar of Iran. This library aims to create a Solar Hijri date library that closely resembles Ruby's built-in date library, providing a seamless experience for users who need to work with the Solar Hijri dates. The conversion algorithm used in this library is inspired by FarsiWeb.
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
- **Parsi::Date** and **Parsi::DateTime**: These objects can be used just like Ruby's `Date` and `DateTime` objects.
|
8
|
+
- **Date Conversion:** Easily convert between Gregorian and Solar Hijri dates.
|
9
|
+
- **Leap Year Calculation:** Determine if a given Solar Hijri year is a leap year.
|
10
|
+
- **Date Parsing and Formatting:** Parse Solar Hijri date strings and format dates in various styles.
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
### Basic Operations
|
15
|
+
|
16
|
+
You can use `Parsi::Date` and `Parsi::DateTime` objects in the same way you use `Date` and `DateTime` objects in Ruby. Here are some examples:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
# Get today's Solar Hijri date
|
20
|
+
a = Parsi::Date.today
|
21
|
+
# => #<Parsi::Date: 1391-08-09 (4912461/2,0/1)>
|
22
|
+
|
23
|
+
# Add 12 months to it
|
24
|
+
b = a >> 12
|
25
|
+
# => #<Parsi::Date: 1392-08-09 (4913193/2,0/1)>
|
26
|
+
|
27
|
+
# Count the number of Sundays between two dates
|
28
|
+
a.upto(b).select{ |d| d.sunday? }.count
|
29
|
+
# => 52
|
30
|
+
|
31
|
+
# Check if a given year is a leap year
|
32
|
+
Parsi::Date.leap?(1391)
|
33
|
+
# => true
|
34
|
+
```
|
35
|
+
|
36
|
+
### Parsing and Formatting Dates
|
37
|
+
|
38
|
+
You can parse Solar Hijri date strings and format them in various styles:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
# Parse a Solar Hijri date string
|
42
|
+
c = Parsi::Date.parse("1391/10/12")
|
43
|
+
# => #<Parsi::Date: 1391-10-12 (4912587/2,0)>
|
44
|
+
|
45
|
+
# Format the date in Persian
|
46
|
+
c.strftime("%A %d %B %Y")
|
47
|
+
# => "سهشنبه 12 دی 1391"
|
48
|
+
|
49
|
+
# Format the date in English
|
50
|
+
c.strftime("%^EA %d %^EB %Y")
|
51
|
+
# => "Seshambe 12 Day 1391"
|
52
|
+
```
|
53
|
+
|
54
|
+
### Converting Between Calendars
|
55
|
+
|
56
|
+
You can easily convert between Gregorian and Solar Hijri dates:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
# Convert a Gregorian date to Solar Hijri
|
60
|
+
d = Date.civil(2012, 10, 30).to_parsi
|
61
|
+
# => #<Parsi::Date: 1391-08-09 (4912461/2,0/1)>
|
62
|
+
|
63
|
+
# Convert a Solar Hijri date back to Gregorian
|
64
|
+
d.to_gregorian
|
65
|
+
# => #<Date: 2012-10-30 ((2456231j,0s,0n),+0s,2299161j)>
|
66
|
+
```
|
67
|
+
|
68
|
+
## Installation
|
69
|
+
|
70
|
+
Add this line to your application's Gemfile:
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
gem 'parsi-date'
|
74
|
+
```
|
75
|
+
|
76
|
+
And then execute:
|
77
|
+
|
78
|
+
```sh
|
79
|
+
bundle install
|
80
|
+
```
|
81
|
+
|
82
|
+
Or install it yourself as:
|
83
|
+
|
84
|
+
```sh
|
85
|
+
gem install parsi-date
|
86
|
+
```
|
87
|
+
|
88
|
+
## License
|
89
|
+
|
90
|
+
The Parsi Date library is open-source software licensed under the MIT license.
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
If you would like to contribute to the development of the Parsi Date library, please feel free to fork the repository and submit pull requests. Contributions, bug reports, and feature requests are welcome and appreciated.
|
data/lib/parsi-date.rb
CHANGED
@@ -135,11 +135,11 @@ module Parsi
|
|
135
135
|
JALALI_EPOCH_IN_AJD = Rational(3896641, 2) # :nodoc:
|
136
136
|
MJD_EPOCH_IN_AJD = Rational(4800001, 2) # 1858-11-17 # :nodoc:
|
137
137
|
UNIX_EPOCH_IN_AJD = Rational(4881175, 2) # 1970-01-01 # :nodoc:
|
138
|
-
JALALI_EPOCH_IN_CJD =
|
138
|
+
JALALI_EPOCH_IN_CJD = 1948320 # :nodoc:
|
139
139
|
MJD_EPOCH_IN_CJD = 2400001 # :nodoc:
|
140
140
|
UNIX_EPOCH_IN_CJD = 2440588 # :nodoc:
|
141
141
|
LD_EPOCH_IN_CJD = 2299160 # :nodoc:
|
142
|
-
DAYS_IN_MONTH = [
|
142
|
+
DAYS_IN_MONTH = [0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29] # :nodoc:
|
143
143
|
|
144
144
|
LEAP_REMINDERS = [1, 5, 9, 13, 17, 22, 26, 30].freeze
|
145
145
|
|
@@ -153,38 +153,43 @@ module Parsi
|
|
153
153
|
|
154
154
|
private
|
155
155
|
|
156
|
-
DAYS_TO_FIRST_OF_MONTH = [nil, 0, 31, 62, 93, 124, 155, 186, 216, 246, 276, 306, 336] # :nodoc:
|
157
|
-
|
158
156
|
# Convert a Civil Date to a Julian Day Number and returns the corresponding Julian Day Number.
|
159
|
-
def civil_to_jd
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
157
|
+
def civil_to_jd(year, month, day) # :nodoc:
|
158
|
+
year -= 1
|
159
|
+
month -= 1
|
160
|
+
day -= 1
|
161
|
+
|
162
|
+
jd = 365*year + (year/33)*8 + (year%33+3)/4;
|
163
|
+
while month > 0
|
164
|
+
jd += DAYS_IN_MONTH[month]
|
165
|
+
month -= 1
|
166
|
+
end
|
167
|
+
|
168
|
+
jd + day + JALALI_EPOCH_IN_CJD
|
168
169
|
end
|
169
170
|
|
170
171
|
# Convert a Julian Day Number to a Civil Date. +jday+ is the Julian Day Number.
|
171
172
|
#
|
172
173
|
# Returns the corresponding [year, month, day_of_month] as a three-element array.
|
173
|
-
def jd_to_civil
|
174
|
-
|
175
|
-
cycle, cyear = depoch.divmod 1029983
|
174
|
+
def jd_to_civil jd
|
175
|
+
jd -= JALALI_EPOCH_IN_CJD
|
176
176
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
177
|
+
n, jd = jd.divmod 12053
|
178
|
+
m, jd = jd.divmod 1461
|
179
|
+
year = 33*n + 4*m + 1
|
180
|
+
|
181
|
+
if jd >= 366
|
182
|
+
n, jd = (jd - 1).divmod 365
|
183
|
+
year += n
|
184
|
+
end
|
185
|
+
|
186
|
+
month = 1
|
187
|
+
while month < 12 && jd >= DAYS_IN_MONTH[month]
|
188
|
+
jd -= DAYS_IN_MONTH[month]
|
189
|
+
month += 1
|
182
190
|
end
|
183
|
-
|
184
|
-
|
185
|
-
month = ((yday <= 186) ? yday / 31.0 : (yday - 6) / 30.0).ceil
|
186
|
-
day = (jday - first_day_of_month(year, month) + 1)
|
187
|
-
[year, month, day]
|
191
|
+
|
192
|
+
[year, month, jd + 1]
|
188
193
|
end
|
189
194
|
|
190
195
|
# Do +year+, +month+, and day-of-month +day+ make a valid Civil Date?
|
@@ -332,7 +337,6 @@ module Parsi
|
|
332
337
|
# Parsi::Date.jd # => #<Parsi::Date: -5335-09-01>
|
333
338
|
#
|
334
339
|
def jd jday=0
|
335
|
-
jd = _valid_jd? jday
|
336
340
|
new! jd_to_ajd(jday, 0, 0), 0
|
337
341
|
end
|
338
342
|
|
@@ -733,7 +737,7 @@ module Parsi
|
|
733
737
|
def marshal_dump() [@ajd, @offset] end
|
734
738
|
|
735
739
|
# Load from Marshal format.
|
736
|
-
def marshal_load(a) @ajd, @
|
740
|
+
def marshal_load(a) @ajd, @offset, = a end
|
737
741
|
end
|
738
742
|
end
|
739
743
|
|
data/lib/version.rb
CHANGED
data/parsi-date.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ['lib']
|
20
20
|
|
21
21
|
s.add_development_dependency("bundler", "~> 2.0")
|
22
|
+
s.add_development_dependency("json", "~> 2.0")
|
22
23
|
s.add_development_dependency("rake", "~> 13.0")
|
23
24
|
s.add_development_dependency("rspec", "~> 3.0")
|
24
25
|
s.add_development_dependency("activerecord", "~> 6.0")
|
@@ -1,57 +1,66 @@
|
|
1
1
|
describe "Parsi::Date#ajd" do
|
2
2
|
it "determines the Astronomical Julian day" do
|
3
|
-
expect
|
3
|
+
expect(Parsi::Date.civil(1391, 8, 6).ajd).to be == Rational(4912455, 2)
|
4
|
+
expect(Parsi::Date.civil(1403, 12, 30).ajd).to be == Rational(4921509, 2)
|
4
5
|
end
|
5
6
|
end
|
6
7
|
|
7
8
|
describe "Parsi::Date#amjd" do
|
8
9
|
it "determines the Astronomical Modified Julian day" do
|
9
|
-
expect
|
10
|
+
expect(Parsi::Date.civil(1391, 8, 6).amjd).to be == 56227
|
11
|
+
expect(Parsi::Date.civil(1403, 12, 30).amjd).to be == 60754
|
10
12
|
end
|
11
13
|
end
|
12
14
|
|
13
15
|
describe "Parsi::Date#mjd" do
|
14
16
|
it "determines the Modified Julian day" do
|
15
|
-
expect
|
17
|
+
expect(Parsi::Date.civil(1391, 8, 6).mjd).to be == 56227
|
18
|
+
expect(Parsi::Date.civil(1403, 12, 30).mjd).to be == 60754
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
22
|
describe "Parsi::Date#ld" do
|
20
|
-
it "determines the
|
21
|
-
expect
|
23
|
+
it "determines the number of days since the Day of Calendar Reform" do
|
24
|
+
expect(Parsi::Date.civil(1391, 8, 6).ld).to be == 157068
|
25
|
+
expect(Parsi::Date.civil(1403, 12, 30).ld).to be == 161595
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
25
29
|
describe "Parsi::Date#year" do
|
26
30
|
it "determines the year" do
|
27
|
-
expect
|
31
|
+
expect(Parsi::Date.civil(1391, 8, 6).year).to be == 1391
|
32
|
+
expect(Parsi::Date.civil(1403, 12, 30).year).to be == 1403
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
31
36
|
describe "Parsi::Date#yday" do
|
32
37
|
it "determines the year" do
|
33
|
-
expect
|
34
|
-
expect
|
38
|
+
expect(Parsi::Date.civil(1391, 1, 17).yday).to be == 17
|
39
|
+
expect(Parsi::Date.civil(1391, 8, 6).yday).to be == 222
|
40
|
+
expect(Parsi::Date.civil(1403, 12, 30).yday).to be == 366
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
44
|
describe "Parsi::Date#mon" do
|
39
45
|
it "determines the month" do
|
40
|
-
expect
|
41
|
-
expect
|
46
|
+
expect(Parsi::Date.civil(1391, 1, 17).mon).to be == 1
|
47
|
+
expect(Parsi::Date.civil(1391, 8, 6).mon).to be == 8
|
48
|
+
expect(Parsi::Date.civil(1403, 12, 30).mon).to be == 12
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
45
52
|
describe "Parsi::Date#mday" do
|
46
53
|
it "determines the day of the month" do
|
47
|
-
expect
|
48
|
-
expect
|
54
|
+
expect(Parsi::Date.civil(1391, 1, 17).mday).to be == 17
|
55
|
+
expect(Parsi::Date.civil(1391, 10, 28).mday).to be == 28
|
56
|
+
expect(Parsi::Date.civil(1403, 12, 30).mday).to be == 30
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
52
60
|
describe "Parsi::Date#wday" do
|
53
61
|
it "determines the week day" do
|
54
|
-
expect
|
55
|
-
expect
|
62
|
+
expect(Parsi::Date.civil(1391, 1, 17).wday).to be == 4
|
63
|
+
expect(Parsi::Date.civil(1391, 8, 6).wday).to be == 6
|
64
|
+
expect(Parsi::Date.civil(1403, 12, 30).wday).to be == 4
|
56
65
|
end
|
57
66
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
describe "Parsi::Date#>>" do
|
2
2
|
it "adds the number of months to a Parsi::Date" do
|
3
|
-
expect
|
3
|
+
expect(Parsi::Date.civil(1391, 2, 27) >> 10).to be == Parsi::Date.civil(1391, 12, 27)
|
4
|
+
expect(Parsi::Date.civil(1403, 11, 30) >> 1).to be == Parsi::Date.civil(1403, 12, 30)
|
4
5
|
end
|
5
6
|
|
6
7
|
it "sets the day to the last day of a month if the day doesn't exist" do
|
7
|
-
expect
|
8
|
+
expect(Parsi::Date.civil(1391, 6, 31) >> 1).to be == Parsi::Date.civil(1391, 7, 30)
|
9
|
+
expect(Parsi::Date.civil(1402, 11, 30) >> 1).to be == Parsi::Date.civil(1402, 12, 29)
|
8
10
|
end
|
9
11
|
|
10
12
|
it "raise a TypeError when passed a Symbol" do
|
data/spec/parsi-date/add_spec.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
describe "Parsi::Date#+" do
|
2
2
|
it "adds the number of days to a Parsi::Date" do
|
3
|
-
expect
|
3
|
+
expect(Parsi::Date.civil(1391, 2, 27) + 10).to be == Parsi::Date.civil(1391, 3, 6)
|
4
|
+
expect(Parsi::Date.civil(1403, 12, 29) + 1).to be == Parsi::Date.civil(1403, 12, 30)
|
5
|
+
expect(Parsi::Date.civil(1403, 12, 30) + 1).to be == Parsi::Date.civil(1404, 1, 1)
|
4
6
|
end
|
5
7
|
|
6
8
|
it "adds a negative number of days to a Parsi::Date" do
|
7
|
-
expect
|
9
|
+
expect(Parsi::Date.civil(1391, 2, 27) + (-10)).to be == Parsi::Date.civil(1391, 2, 17)
|
8
10
|
end
|
9
11
|
|
10
12
|
it "raises a TypeError when passed a Symbol" do
|
@@ -2,29 +2,29 @@ require 'date'
|
|
2
2
|
|
3
3
|
describe "Parsi::Date#<=>" do
|
4
4
|
it "returns 0 when two dates are equal" do
|
5
|
-
expect
|
6
|
-
expect
|
5
|
+
expect(Parsi::Date.civil(1391, 4, 6) <=> Parsi::Date.civil(1391, 4, 6)).to be == 0
|
6
|
+
expect(Parsi::Date.civil(1391, 4, 6) <=> Date.civil(2012, 6, 26)).to be == 0
|
7
7
|
end
|
8
8
|
|
9
9
|
it "returns -1 when self is less than another date" do
|
10
|
-
expect
|
11
|
-
expect
|
10
|
+
expect(Parsi::Date.civil(1391, 4, 5) <=> Parsi::Date.civil(1391, 4, 6)).to be == -1
|
11
|
+
expect(Parsi::Date.civil(1391, 4, 5) <=> Date.civil(2012, 6, 26)).to be == -1
|
12
12
|
end
|
13
13
|
|
14
14
|
it "returns 1 when self is greater than another date" do
|
15
|
-
expect
|
16
|
-
expect
|
15
|
+
expect(Parsi::Date.civil(1392, 4, 7) <=> Parsi::Date.civil(1391, 4, 6)).to be == 1
|
16
|
+
expect(Parsi::Date.civil(1391, 4, 7) <=> Date.civil(2012, 6, 26)).to be == 1
|
17
17
|
end
|
18
18
|
|
19
19
|
it "returns 0 when self is equal to a Numeric" do
|
20
|
-
expect
|
20
|
+
expect(Parsi::Date.civil(1391, 4, 6) <=> Rational(4912209,2)).to be == 0
|
21
21
|
end
|
22
22
|
|
23
23
|
it "returns -1 when self is less than a Numeric" do
|
24
|
-
expect
|
24
|
+
expect(Parsi::Date.civil(1391, 4, 6) <=> Rational(4912210,2)).to be == -1
|
25
25
|
end
|
26
26
|
|
27
27
|
it "returns 1 when self is greater than a Numeric" do
|
28
|
-
expect
|
28
|
+
expect(Parsi::Date.civil(1391, 4, 6) <=> Rational(4912208,2)).to be == 1
|
29
29
|
end
|
30
30
|
end
|
@@ -1,34 +1,38 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
describe "Date constants" do
|
3
3
|
it "defines MONTHNAMES" do
|
4
|
-
expect
|
5
|
-
%w(فروردین اردیبهشت خرداد تیر مرداد شهریور مهر آبان آذر دی بهمن اسفند)
|
4
|
+
expect(Parsi::Date::MONTHNAMES).to be ==
|
5
|
+
[nil] + %w(فروردین اردیبهشت خرداد تیر مرداد شهریور مهر آبان آذر دی بهمن اسفند)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "defines EN_MONTHNAMES" do
|
9
|
-
expect
|
10
|
-
%w(farvardin ordibehesht khordad tir mordad shahrivar mehr aban azar day bahman esfand)
|
9
|
+
expect(Parsi::Date::EN_MONTHNAMES).to be ==
|
10
|
+
[nil] + %w(farvardin ordibehesht khordad tir mordad shahrivar mehr aban azar day bahman esfand)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "defines ABBR_MONTHNAMES" do
|
14
|
-
expect
|
15
|
-
%w(far ord kho tir mor sha meh abn azr day bah esf)
|
14
|
+
expect(Parsi::Date::ABBR_MONTHNAMES).to be ==
|
15
|
+
[nil] + %w(far ord kho tir mor sha meh abn azr day bah esf)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "defines DAYNAMES" do
|
19
|
-
expect
|
19
|
+
expect(Parsi::Date::DAYNAMES).to be ==
|
20
|
+
%w(یکشنبه دوشنبه سهشنبه چهارشنبه پنجشنبه جمعه شنبه)
|
20
21
|
end
|
21
22
|
|
22
23
|
it "defines EN_DAYNAMES" do
|
23
|
-
expect
|
24
|
+
expect(Parsi::Date::EN_DAYNAMES).to be ==
|
25
|
+
%w(yekshanbe doshanbe seshanbe chaharshanbe panjshanbe jomee shanbe)
|
24
26
|
end
|
25
27
|
|
26
28
|
it "defines ABBR_DAYNAMES" do
|
27
|
-
expect
|
29
|
+
expect(Parsi::Date::ABBR_DAYNAMES).to be ==
|
30
|
+
%w(۱ش ۲ش ۳ش ۴ش ۵ش ج ش)
|
28
31
|
end
|
29
32
|
|
30
33
|
it "defines ABBR_EN_DAYNAMES" do
|
31
|
-
expect
|
34
|
+
expect(Parsi::Date::ABBR_EN_DAYNAMES).to be ==
|
35
|
+
%w(ye do se ch pj jo sh)
|
32
36
|
end
|
33
37
|
|
34
38
|
it "freezes MONTHNAMES, DAYNAMES, EN_DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYSNAMES" do
|
@@ -21,17 +21,18 @@ describe Parsi::Date do
|
|
21
21
|
|
22
22
|
it "constructs a Date for 1/1/1 by default" do
|
23
23
|
date = Parsi::Date.civil
|
24
|
-
expect
|
25
|
-
expect
|
26
|
-
expect
|
24
|
+
expect(date.year ).to be == 1
|
25
|
+
expect(date.month).to be == 1
|
26
|
+
expect(date.day ).to be == 1
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
context "ordinal" do
|
31
31
|
it "constructs a Date object from an ordinal date" do
|
32
|
-
expect
|
33
|
-
expect
|
34
|
-
expect
|
32
|
+
expect(Parsi::Date.ordinal(1390) ).to be == Parsi::Date.civil(1390, 1, 1)
|
33
|
+
expect(Parsi::Date.ordinal(1390, 7) ).to be == Parsi::Date.civil(1390, 1, 7)
|
34
|
+
expect(Parsi::Date.ordinal(1390, 100)).to be == Parsi::Date.civil(1390, 4, 7)
|
35
|
+
expect(Parsi::Date.ordinal(1403, 366)).to be == Parsi::Date.civil(1403, 12, 30)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -39,20 +40,20 @@ describe Parsi::Date do
|
|
39
40
|
it "parses date from strings" do
|
40
41
|
['1391/8/6', '1391-8-6', '1391 8 6', '1391 8 6', '13910806'].each do |date_string|
|
41
42
|
date = Parsi::Date.parse date_string
|
42
|
-
expect
|
43
|
+
expect([date.year, date.month, date.day]).to be == [1391, 8, 6]
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
it "completes century when second arg is true" do
|
47
48
|
allow(Date).to receive(:today) { Date.new 2012, 10, 26 }
|
48
49
|
date = Parsi::Date.parse '91/8/5', true
|
49
|
-
expect
|
50
|
+
expect([date.year, date.month, date.day]).to be == [1391, 8, 5]
|
50
51
|
end
|
51
52
|
|
52
53
|
it "raises ArgumentError on invalid date string" do
|
53
|
-
expect { date = Parsi::Date.parse '1390/12/30'
|
54
|
+
expect { date = Parsi::Date.parse '1390/12/30' }.to raise_error(ArgumentError)
|
54
55
|
expect { date = Parsi::Date.parse 'bad date string' }.to raise_error(ArgumentError)
|
55
|
-
expect { date = Parsi::Date.parse '12-30-1390'
|
56
|
+
expect { date = Parsi::Date.parse '12-30-1390' }.to raise_error(ArgumentError)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
@@ -1,21 +1,26 @@
|
|
1
1
|
describe "Parsi::Date.jd" do
|
2
2
|
it "constructs a date form given Chronological Julian day number" do
|
3
|
-
expect
|
4
|
-
expect
|
3
|
+
expect(Parsi::Date.jd(2456228)).to be == Parsi::Date.civil(1391, 8, 6)
|
4
|
+
expect(Parsi::Date.jd(2456229)).to be == Parsi::Date.civil(1391, 8, 7)
|
5
|
+
expect(Parsi::Date.jd(2456229)).to be == Parsi::Date.civil(1391, 8, 7)
|
6
|
+
expect(Parsi::Date.jd(2460755)).to be == Parsi::Date.civil(1403, 12, 30)
|
7
|
+
expect(Parsi::Date.jd(2460756)).to be == Parsi::Date.civil(1404, 1, 1)
|
5
8
|
end
|
6
9
|
|
7
10
|
it "returns a Date object representing Julian day 0 if no arguments passed"do
|
8
|
-
expect
|
11
|
+
expect(Parsi::Date.jd).to be == Parsi::Date.civil(-5334, 9, 3)
|
9
12
|
end
|
10
13
|
|
11
14
|
it "constructs a Date object if passed a negative number" do
|
12
|
-
expect
|
15
|
+
expect(Parsi::Date.jd(-1)).to be == Parsi::Date.civil(-5334, 9, 2)
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
16
19
|
describe "Parsi::Date#jd" do
|
17
20
|
it "determines the Julian day for a Date object" do
|
18
|
-
expect
|
21
|
+
expect(Parsi::Date.civil(1391, 8, 7).jd ).to be == 2456229
|
22
|
+
expect(Parsi::Date.civil(1403, 12, 30).jd).to be == 2460755
|
23
|
+
expect(Parsi::Date.civil(1404, 1, 1).jd ).to be == 2460756
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
@@ -23,7 +28,10 @@ describe "Parsi::Date#to_gregorian" do
|
|
23
28
|
it "converts date to Gregorian date" do
|
24
29
|
date = Parsi::Date.civil(1391, 8, 7).to_gregorian
|
25
30
|
expect(date).to be_a(Date)
|
26
|
-
expect
|
31
|
+
expect(date).to be == Date.civil(2012, 10, 28)
|
32
|
+
|
33
|
+
expect(Parsi::Date.civil(1366, 11, 14).to_gregorian).to be == Date.civil(1988, 2, 3)
|
34
|
+
expect(Parsi::Date.civil(1403, 12, 30).to_gregorian).to be == Date.civil(2025, 3, 20)
|
27
35
|
end
|
28
36
|
end
|
29
37
|
|
@@ -31,6 +39,9 @@ describe "Date#to_parsi" do
|
|
31
39
|
it "converts date to Parsi date" do
|
32
40
|
date = Date.civil(2012, 10, 28).to_parsi
|
33
41
|
expect(date).to be_a(Parsi::Date)
|
34
|
-
expect
|
42
|
+
expect(date).to be == Parsi::Date.civil(1391, 8, 7)
|
43
|
+
|
44
|
+
expect(Date.civil(1988, 2, 3).to_parsi ).to be == Parsi::Date.civil(1366, 11, 14)
|
45
|
+
expect(Date.civil(2025, 3, 20).to_parsi).to be == Parsi::Date.civil(1403, 12, 30)
|
35
46
|
end
|
36
47
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
describe "Parsi::Date#leap?" do
|
2
2
|
it "returns true if a year is a leap year in the Parsi (Jalali) calendar" do
|
3
|
-
expect
|
4
|
-
expect
|
5
|
-
expect
|
6
|
-
expect
|
3
|
+
expect(Parsi::Date.leap?(1387)).to be true
|
4
|
+
expect(Parsi::Date.leap?(1391)).to be true
|
5
|
+
expect(Parsi::Date.leap?(1395)).to be true
|
6
|
+
expect(Parsi::Date.leap?(1403)).to be true
|
7
7
|
end
|
8
8
|
|
9
9
|
it "returns false if a year is not a leap year in the Parsi (Jalali) calendar" do
|
10
|
-
expect
|
11
|
-
expect
|
12
|
-
expect
|
13
|
-
expect
|
10
|
+
expect(Parsi::Date.leap?(1390)).to be false
|
11
|
+
expect(Parsi::Date.leap?(1392)).to be false
|
12
|
+
expect(Parsi::Date.leap?(1400)).to be false
|
13
|
+
expect(Parsi::Date.leap?(1404)).to be false
|
14
14
|
end
|
15
15
|
end
|
@@ -5,23 +5,23 @@ describe "Parsi::Date#step" do
|
|
5
5
|
de = Parsi::Date.civil(1391, 9, 29)
|
6
6
|
count = 0
|
7
7
|
de.step(ds) do |d|
|
8
|
-
expect
|
9
|
-
expect
|
8
|
+
expect(d).to be <= ds
|
9
|
+
expect(d).to be >= de
|
10
10
|
count += 1
|
11
11
|
end
|
12
|
-
expect
|
12
|
+
expect(count).to be == 13
|
13
13
|
|
14
14
|
count = 0
|
15
15
|
de.step(ds, 5) do |d|
|
16
|
-
expect
|
17
|
-
expect
|
16
|
+
expect(d).to be <= ds
|
17
|
+
expect(d).to be >= de
|
18
18
|
count += 1
|
19
19
|
end
|
20
|
-
expect
|
20
|
+
expect(count).to be == 3
|
21
21
|
|
22
22
|
count = 0
|
23
23
|
ds.step(de) do |d|; count += 1; end
|
24
|
-
expect
|
24
|
+
expect(count).to be == 0
|
25
25
|
end
|
26
26
|
|
27
27
|
it "steps backward in time" do
|
@@ -29,22 +29,22 @@ describe "Parsi::Date#step" do
|
|
29
29
|
de = Parsi::Date.civil(1390, 3, 29)
|
30
30
|
count = 0
|
31
31
|
ds.step(de, -1) do |d|
|
32
|
-
expect
|
33
|
-
expect
|
32
|
+
expect(d).to be <= ds
|
33
|
+
expect(d).to be >= de
|
34
34
|
count += 1
|
35
35
|
end
|
36
|
-
expect
|
36
|
+
expect(count).to be == 17
|
37
37
|
|
38
38
|
count = 0
|
39
39
|
ds.step(de, -5) do |d|
|
40
|
-
expect
|
41
|
-
expect
|
40
|
+
expect(d).to be <= ds
|
41
|
+
expect(d).to be >= de
|
42
42
|
count += 1
|
43
43
|
end
|
44
|
-
expect
|
44
|
+
expect(count).to be == 4
|
45
45
|
|
46
46
|
count = 0
|
47
47
|
de.step(ds, -1) do |d|; count += 1; end
|
48
|
-
expect
|
48
|
+
expect(count).to be == 0
|
49
49
|
end
|
50
50
|
end
|
@@ -2,78 +2,78 @@
|
|
2
2
|
describe "Parsi::Date#strftime" do
|
3
3
|
|
4
4
|
it "is able to print the date" do
|
5
|
-
expect
|
5
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime).to be == "1390/04/06"
|
6
6
|
end
|
7
7
|
|
8
8
|
it "is able to print the full day name" do
|
9
|
-
expect
|
9
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%A")).to be == "دوشنبه"
|
10
10
|
end
|
11
11
|
|
12
12
|
it "is able to print the short day name" do
|
13
|
-
expect
|
13
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%a")).to be == "۲ش"
|
14
14
|
end
|
15
15
|
|
16
16
|
it "is able to print the full month name" do
|
17
|
-
expect
|
18
|
-
expect
|
19
|
-
expect
|
17
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%B") ).to be == "تیر"
|
18
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%EB") ).to be == "tir"
|
19
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%^EB")).to be == "Tir"
|
20
20
|
end
|
21
21
|
|
22
22
|
it "is able to print the short month name" do
|
23
|
-
expect
|
24
|
-
expect
|
25
|
-
expect
|
26
|
-
expect
|
27
|
-
expect
|
23
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%b") ).to be == "tir"
|
24
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%h") ).to be == "tir"
|
25
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%^b")).to be == "Tir"
|
26
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%^h")).to be == "Tir"
|
27
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%b") ).to be == Parsi::Date.civil(1390, 4, 6).strftime("%h")
|
28
28
|
end
|
29
29
|
|
30
30
|
it "is able to print the century" do
|
31
|
-
expect
|
31
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%C")).to be == "13"
|
32
32
|
end
|
33
33
|
|
34
34
|
it "is able to print the month day with leading zeroes" do
|
35
|
-
expect
|
36
|
-
expect
|
35
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%d")).to be == "06"
|
36
|
+
expect(Parsi::Date.civil(1390, 4, 16).strftime("%d")).to be == "16"
|
37
37
|
end
|
38
38
|
|
39
39
|
it "is able to print the month day with leading spaces and without em" do
|
40
|
-
expect
|
41
|
-
expect
|
42
|
-
expect
|
40
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%-d")).to be == "6"
|
41
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%e") ).to be == " 6"
|
42
|
+
expect(Parsi::Date.civil(1390, 4, 16).strftime("%e") ).to be == "16"
|
43
43
|
end
|
44
44
|
|
45
45
|
it "is able to print the month with leading zeroes, spaces and none" do
|
46
|
-
expect
|
47
|
-
expect
|
48
|
-
expect
|
49
|
-
expect
|
50
|
-
expect
|
51
|
-
expect
|
46
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%m") ).to be == "04"
|
47
|
+
expect(Parsi::Date.civil(1390, 11, 6).strftime("%m") ).to be == "11"
|
48
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%_m")).to be == " 4"
|
49
|
+
expect(Parsi::Date.civil(1390, 11, 6).strftime("%_m")).to be == "11"
|
50
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%-m")).to be == "4"
|
51
|
+
expect(Parsi::Date.civil(1390, 11, 6).strftime("%-m")).to be == "11"
|
52
52
|
end
|
53
53
|
|
54
54
|
it "is able to add a newline" do
|
55
|
-
expect
|
55
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%n")).to be == "\n"
|
56
56
|
end
|
57
57
|
|
58
58
|
it "is able to add a tab" do
|
59
|
-
expect
|
59
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%t")).to be == "\t"
|
60
60
|
end
|
61
61
|
|
62
62
|
it "is able to show the week day" do
|
63
|
-
expect
|
64
|
-
expect
|
63
|
+
expect(Parsi::Date.civil(1390, 4, 11).strftime("%w")).to be == "6"
|
64
|
+
expect(Parsi::Date.civil(1390, 4, 12).strftime("%w")).to be == "0"
|
65
65
|
end
|
66
66
|
|
67
67
|
it "is able to show the year in YYYY format" do
|
68
|
-
expect
|
68
|
+
expect(Parsi::Date.civil(1390, 4, 9).strftime("%Y")).to be == "1390"
|
69
69
|
end
|
70
70
|
|
71
71
|
it "is able to show the year in YY format" do
|
72
|
-
expect
|
72
|
+
expect(Parsi::Date.civil(1390, 4, 9).strftime("%y")).to be == "90"
|
73
73
|
end
|
74
74
|
|
75
75
|
it "is able to escape the % character" do
|
76
|
-
expect
|
76
|
+
expect(Parsi::Date.civil(1390, 4, 9).strftime("%%")).to be == "%"
|
77
77
|
end
|
78
78
|
|
79
79
|
############################
|
@@ -81,28 +81,28 @@ describe "Parsi::Date#strftime" do
|
|
81
81
|
############################
|
82
82
|
|
83
83
|
it "is able to print the date in full" do
|
84
|
-
expect
|
85
|
-
expect
|
84
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%c")).to be == "۲ش 6 تیر 1390"
|
85
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%c")).to be == Parsi::Date.civil(1390, 4, 6).strftime('%a %-d %B %Y')
|
86
86
|
end
|
87
87
|
|
88
88
|
it "is able to print the date with slashes" do
|
89
|
-
expect
|
90
|
-
expect
|
89
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%D")).to be == "90/04/06"
|
90
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%D")).to be == Parsi::Date.civil(1390, 4, 6).strftime('%y/%m/%d')
|
91
91
|
end
|
92
92
|
|
93
93
|
it "is able to print the date as YYYY-MM-DD" do
|
94
|
-
expect
|
95
|
-
expect
|
94
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%F")).to be == "1390-04-06"
|
95
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%F")).to be == Parsi::Date.civil(1390, 4, 6).strftime('%Y-%m-%d')
|
96
96
|
end
|
97
97
|
|
98
98
|
it "is able to show the commercial week" do
|
99
|
-
expect
|
100
|
-
expect
|
99
|
+
expect(Parsi::Date.civil(1390, 4, 9).strftime("%v")).to be == " 9-تیر-1390"
|
100
|
+
expect(Parsi::Date.civil(1390, 4, 9).strftime("%v")).to be == Parsi::Date.civil(1390, 4, 9).strftime('%e-%B-%Y')
|
101
101
|
end
|
102
102
|
|
103
103
|
it "is able to show YY/MM/DD" do
|
104
|
-
expect
|
105
|
-
expect
|
104
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%x")).to be == "90/04/06"
|
105
|
+
expect(Parsi::Date.civil(1390, 4, 6).strftime("%x")).to be == Parsi::Date.civil(1390, 4, 6).strftime('%y/%m/%d')
|
106
106
|
end
|
107
107
|
|
108
108
|
end
|
@@ -1,17 +1,17 @@
|
|
1
1
|
describe "Parsi::Date#cwday?" do
|
2
2
|
it "returns the day of calendar week (1-7, Monday is 1)" do
|
3
|
-
expect
|
4
|
-
expect
|
3
|
+
expect(Parsi::Date.civil(1393, 12, 3).cwday).to be == 7
|
4
|
+
expect(Parsi::Date.civil(1394, 1, 3).cwday).to be == 1
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "Parsi::Date#cweek?" do
|
9
9
|
it "returns the calendar week number (1-53)" do
|
10
|
-
expect
|
11
|
-
expect
|
12
|
-
expect
|
13
|
-
expect
|
14
|
-
expect
|
15
|
-
expect
|
10
|
+
expect(Parsi::Date.civil(1393, 11, 30).cweek).to be == 48
|
11
|
+
expect(Parsi::Date.civil(1393, 12, 1).cweek ).to be == 48
|
12
|
+
expect(Parsi::Date.civil(1393, 12, 29).cweek).to be == 52
|
13
|
+
expect(Parsi::Date.civil(1394, 1, 1).cweek ).to be == 1
|
14
|
+
expect(Parsi::Date.civil(1394, 1, 7).cweek ).to be == 1
|
15
|
+
expect(Parsi::Date.civil(1394, 1, 8).cweek ).to be == 2
|
16
16
|
end
|
17
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parsi-date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hassan Zamani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +106,7 @@ files:
|
|
92
106
|
- ".rspec"
|
93
107
|
- Gemfile
|
94
108
|
- MIT-LICENSE
|
95
|
-
- README.
|
109
|
+
- README.md
|
96
110
|
- lib/parsi-date-accessors.rb
|
97
111
|
- lib/parsi-date.rb
|
98
112
|
- lib/parsi-datetime.rb
|
@@ -130,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
144
|
- !ruby/object:Gem::Version
|
131
145
|
version: '0'
|
132
146
|
requirements: []
|
133
|
-
rubygems_version: 3.3.
|
147
|
+
rubygems_version: 3.3.25
|
134
148
|
signing_key:
|
135
149
|
specification_version: 4
|
136
150
|
summary: Solar Hijri (Jalali, Persian, Parsi) date library for Ruby
|
data/README.rdoc
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
= Parsi Date
|
2
|
-
|
3
|
-
This is an implementation of {Solar Hijri Calendar}[http://en.wikipedia.org/wiki/Solar_Hijri_calendar]
|
4
|
-
(some times referred to as Jalali or Persian Calendar) which is Iran's official calendar.
|
5
|
-
Main aim of this gem is to create a Solar Hijri date library as close as possible to the built-in date library.
|
6
|
-
Conversion algorithm originally adopted from {here}[http://www.fourmilab.ch/documents/calendar/].
|
7
|
-
|
8
|
-
== Usage
|
9
|
-
|
10
|
-
You can use <tt>Parsi::Date<\tt> and <tt>Parsi::DateTime<\tt> objects as +Date+ and +DateTime+ objects
|
11
|
-
For example:
|
12
|
-
|
13
|
-
a = Parsi::Date.today # => #<Parsi::Date: 1391-08-09 (4912461/2,0/1)>
|
14
|
-
b = a >> 12 # => #<Parsi::Date: 1392-08-09 (4913193/2,0/1)>
|
15
|
-
a.upto(b).select{ |d| d.sunday? }.count # => 52
|
16
|
-
|
17
|
-
Parsi::Date.leap? 1391 # => true
|
18
|
-
|
19
|
-
c = Parsi::Date.parse "1391/10/12" # => #<Parsi::Date: 1391-10-12 (4912587/2,0)>
|
20
|
-
c.strftime "%A %d %B %Y" # => "سهشنبه 12 دی 1391"
|
21
|
-
c.strftime "%^EA %d %^EB %Y" # => "Seshambe 12 Day 1391"
|
22
|
-
|
23
|
-
For converting a +Date+ or +DateTime+ object just call +to_parsi+ (aliased to +jalali+ and +to_jalali+) on it.
|
24
|
-
To convert back use +to_gregorian+.
|
25
|
-
|
26
|
-
d = Date.civil(2012, 10, 30).to_parsi # => #<Parsi::Date: 1391-08-09 (4912461/2,0/1)>
|
27
|
-
d.to_gregorian # => #<Date: 2012-10-30 ((2456231j,0s,0n),+0s,2299161j)>
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
Copyright (c) 2012 Hassan Zamani, released under the MIT license.
|