parsi-date 0.2.5 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c659ed96728dc1eea224fa8524225fff7a8a61e
4
- data.tar.gz: 03c302ac94bdf70c37d25fb7e92d6bce7bfdcba0
3
+ metadata.gz: 09d7a4dd729c919bfe1581622f91a4bbd6683c07
4
+ data.tar.gz: 5ecfbdb3ca6b71f33801bc23e982d92216b27f55
5
5
  SHA512:
6
- metadata.gz: 87d68ea5bffbd765e1852238c4bf57a391aec13972d40dbb1a51bdab1ca649ed0c554058ac8e16ae3f8dcababa7910e9f2d0c916db066db5fbb860a5a98c8e82
7
- data.tar.gz: 5d6f2e51f666ad0b0bf3c7c60e08c26fab43eb875d5efb386ebb16ccdc647d49c285ec03cf2c693babf899d2c6afd09a7227cb5d4a03cb7e8189fe2f7688966c
6
+ metadata.gz: 2ddd7582efd18f2a11529c84e40bcc025acdcccc49312f6e03c2a6056b248d72c55058c1c35ed7d0f7f8b9787ca223bc0fea87c0dc4cda160b91b7b57f445d72
7
+ data.tar.gz: 15e6155dfec566a015303c58e16518e20e9e67c72e9093f9bfcf601c63408dbda1fccb0faaf2f7ac8229a77afd3b75bc3bcce3b009b68902f02ef3db9e171802
data/lib/parsi-date.rb CHANGED
@@ -576,6 +576,16 @@ module Parsi
576
576
  self + (jd2 - jd)
577
577
  end
578
578
 
579
+ # Returns the day of calendar week (1-7, Monday is 1)
580
+ def cwday
581
+ to_gregorian.cwday
582
+ end
583
+
584
+ # Returns the calendar week number (1-53).
585
+ def cweek
586
+ (jd - Date.send(:first_day_of_year, year)) / 7 + 1
587
+ end
588
+
579
589
  # Return a new Date object that is +n+ months earlier than the current one.
580
590
  #
581
591
  # If the day-of-the-month of the current Date is greater than the last day of
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Parsi
2
2
  class Date
3
- VERSION = "0.2.5"
3
+ VERSION = "0.2.6"
4
4
  end
5
5
  end
@@ -2,14 +2,14 @@ require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
3
  describe "Parsi::Date#leap?" do
4
4
  it "returns true if a year is a leap year in the Parsi (Jalali) calendar" do
5
- Parsi::Date.leap?(1387).should be_true
6
- Parsi::Date.leap?(1391).should be_true
7
- Parsi::Date.leap?(1395).should be_true
5
+ Parsi::Date.leap?(1387).should be_truthy
6
+ Parsi::Date.leap?(1391).should be_truthy
7
+ Parsi::Date.leap?(1395).should be_truthy
8
8
  end
9
9
 
10
10
  it "returns false if a year is not a leap year in the Parsi (Jalali) calendar" do
11
- Parsi::Date.leap?(1390).should be_false
12
- Parsi::Date.leap?(1392).should be_false
13
- Parsi::Date.leap?(1400).should be_false
11
+ Parsi::Date.leap?(1390).should be_falsey
12
+ Parsi::Date.leap?(1392).should be_falsey
13
+ Parsi::Date.leap?(1400).should be_falsey
14
14
  end
15
- end
15
+ end
@@ -0,0 +1,16 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe "Parsi::Date#cwday?" do
4
+ it "returns the day of calendar week (1-7, Monday is 1)" do
5
+ Parsi::Date.civil(1393, 12, 3).cwday.should == 7
6
+ Parsi::Date.civil(1394, 1, 3).cwday.should == 1
7
+ end
8
+ end
9
+
10
+ describe "Parsi::Date#cweek?" do
11
+ it "returns the calendar week number (1-53)" do
12
+ Parsi::Date.civil(1394, 1, 3).cweek.should == 1
13
+ Parsi::Date.civil(1394, 1, 7).cweek.should == 1
14
+ Parsi::Date.civil(1394, 1, 8).cweek.should == 2
15
+ end
16
+ 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.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hassan Zamani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-12 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,7 @@ files:
80
80
  - spec/parsi-date/leap_spec.rb
81
81
  - spec/parsi-date/step_spec.rb
82
82
  - spec/parsi-date/strftime_spec.rb
83
+ - spec/parsi-date/week_methods_spec.rb
83
84
  - spec/spec_helper.rb
84
85
  homepage: http://github.com/hzamani/parsi-date
85
86
  licenses:
@@ -101,9 +102,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
102
  version: '0'
102
103
  requirements: []
103
104
  rubyforge_project:
104
- rubygems_version: 2.2.0
105
+ rubygems_version: 2.4.5
105
106
  signing_key:
106
107
  specification_version: 4
107
108
  summary: Solar Hijri (Jalali, Persian, Parsi) date library for Ruby
108
- test_files: []
109
+ test_files:
110
+ - spec/parsi-date/accessor_spec.rb
111
+ - spec/parsi-date/add_month_spec.rb
112
+ - spec/parsi-date/add_spec.rb
113
+ - spec/parsi-date/comp_spec.rb
114
+ - spec/parsi-date/constants_spec.rb
115
+ - spec/parsi-date/construction_spec.rb
116
+ - spec/parsi-date/conversion_spec.rb
117
+ - spec/parsi-date/leap_spec.rb
118
+ - spec/parsi-date/step_spec.rb
119
+ - spec/parsi-date/strftime_spec.rb
120
+ - spec/parsi-date/week_methods_spec.rb
121
+ - spec/spec_helper.rb
109
122
  has_rdoc: