fat_core 4.8.0 → 4.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fat_core/date.rb +8 -4
- data/lib/fat_core/version.rb +1 -1
- data/spec/lib/date_spec.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1ee6aa869e6ebae3f5bc14e8be07629a0fa26f0b077975bbddd920c94c5df9b
|
4
|
+
data.tar.gz: e2d4197028b13d4bfb29365b2fe5bca3f568678bd7fdc391616ea30432d34617
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74418e533e0d3f826866b6d1cf4e7614ea4897475f7254f9388c689f663928e484b4dd2109b541cb87775b5d43bb5d74e37c1a9a865f816d7ee36bec00beba46
|
7
|
+
data.tar.gz: 1ac7754b460710b1f0f346f75285cc63c7739f32d46e4533a451a90757d2ca111c110869260073b5104a9e0c53f06b02f9de9ce8b2cf09515892c3fa7d24273b
|
data/lib/fat_core/date.rb
CHANGED
@@ -497,12 +497,16 @@ module FatCore
|
|
497
497
|
# :category: Relative ::Dates
|
498
498
|
|
499
499
|
# Return the date that is the last day of the commercial biweek in which
|
500
|
-
# self falls. A biweek is a period of two commercial weeks starting with
|
501
|
-
# odd-numbered week and with each week starting in Monday and ending on
|
500
|
+
# self falls. A biweek is a period of two commercial weeks starting with
|
501
|
+
# an odd-numbered week and with each week starting in Monday and ending on
|
502
502
|
# Sunday. So this will always return a Sunday in an even-numbered week.
|
503
|
-
#
|
503
|
+
# In the last week of the year (if it is not part of next year's first
|
504
|
+
# week) the end of the biweek will not extend beyond self's week, so that
|
505
|
+
# week 1 of the following year will start a new biweek. @return [::Date]
|
504
506
|
def end_of_biweek
|
505
|
-
if cweek.
|
507
|
+
if cweek >= 52 && end_of_week(:monday).year > year
|
508
|
+
end_of_week(:monday)
|
509
|
+
elsif cweek.odd?
|
506
510
|
(self + 1.week).end_of_week(:monday)
|
507
511
|
else
|
508
512
|
end_of_week(:monday)
|
data/lib/fat_core/version.rb
CHANGED
data/spec/lib/date_spec.rb
CHANGED
@@ -577,6 +577,10 @@ describe Date do
|
|
577
577
|
.to eq Date.parse('2013-11-17')
|
578
578
|
expect(Date.parse('2013-03-11')).to be_beginning_of_biweek
|
579
579
|
expect(Date.parse('2013-03-24')).to be_end_of_biweek
|
580
|
+
expect(Date.parse('2013-12-30').end_of_biweek)
|
581
|
+
.to eq Date.parse('2014-01-12')
|
582
|
+
expect(Date.parse('2009-12-30').end_of_biweek)
|
583
|
+
.to eq Date.parse('2010-01-03')
|
580
584
|
end
|
581
585
|
|
582
586
|
it 'should know about weeks' do
|