fat_core 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66024aa4a8a016a61e9b00c676c144f2b490eb30
4
- data.tar.gz: 4036617bcc1deaefcc3f0ad878e14c950e538869
3
+ metadata.gz: 864810f594f41bc38df56e4968c5c945c95a9fdf
4
+ data.tar.gz: 6aae1699bfce083fa87f859b4842ec2f3f666cfa
5
5
  SHA512:
6
- metadata.gz: 758f49b0bb0f126c9bbc71ab80f46c292ad12dcf71ab78da171b2f5a74e31974f20641da5a79d8979fccacc87796f3f8a2ea671bfad13fd661dabcbe24e17f8d
7
- data.tar.gz: 05de2534362aed6b2e9e88e906d34ce01ee49fc24fe04429301247b35d9b3daf0c2c9df4275d51ce83f3f68ff6a4f5f1ea0e34215c466d932b4142b5404386fa
6
+ metadata.gz: 058e2009876d4a273c81d0cde59c1f24f8075e61d752cf0db2910f38ea112ac5e5797286b002908d1f087d2922cc48645d060c0dc6958d41a86d72bac043cdb6
7
+ data.tar.gz: 98188d77914b9fcef0deab00faadcfc152e72f5142f6fb39b0dae316b2e8605ec46607a75db2b621b1b095fd293f5554d03d26c7457a9edb8b99634af1b5f6f4
data/lib/fat_core/date.rb CHANGED
@@ -298,61 +298,61 @@ class Date
298
298
  end
299
299
 
300
300
  def beginning_of_year?
301
- self.beginning_of_year == self
301
+ beginning_of_year == self
302
302
  end
303
303
 
304
304
  def end_of_year?
305
- self.end_of_year == self
305
+ end_of_year == self
306
306
  end
307
307
 
308
308
  def beginning_of_quarter?
309
- self.beginning_of_quarter == self
309
+ beginning_of_quarter == self
310
310
  end
311
311
 
312
312
  def end_of_quarter?
313
- self.end_of_quarter == self
313
+ end_of_quarter == self
314
314
  end
315
315
 
316
316
  def beginning_of_bimonth?
317
317
  month % 2 == 1 &&
318
- self.beginning_of_month == self
318
+ beginning_of_month == self
319
319
  end
320
320
 
321
321
  def end_of_bimonth?
322
322
  month % 2 == 0 &&
323
- self.end_of_month == self
323
+ end_of_month == self
324
324
  end
325
325
 
326
326
  def beginning_of_month?
327
- self.beginning_of_month == self
327
+ beginning_of_month == self
328
328
  end
329
329
 
330
330
  def end_of_month?
331
- self.end_of_month == self
331
+ end_of_month == self
332
332
  end
333
333
 
334
334
  def beginning_of_semimonth?
335
- self.beginning_of_semimonth == self
335
+ beginning_of_semimonth == self
336
336
  end
337
337
 
338
338
  def end_of_semimonth?
339
- self.end_of_semimonth == self
339
+ end_of_semimonth == self
340
340
  end
341
341
 
342
342
  def beginning_of_biweek?
343
- self.beginning_of_biweek == self
343
+ beginning_of_biweek == self
344
344
  end
345
345
 
346
346
  def end_of_biweek?
347
- self.end_of_biweek == self
347
+ end_of_biweek == self
348
348
  end
349
349
 
350
350
  def beginning_of_week?
351
- self.beginning_of_week == self
351
+ beginning_of_week == self
352
352
  end
353
353
 
354
354
  def end_of_week?
355
- self.end_of_week == self
355
+ end_of_week == self
356
356
  end
357
357
 
358
358
  def expand_to_period(sym)
@@ -518,12 +518,12 @@ class Date
518
518
 
519
519
  def easter_this_year
520
520
  # Return the date of Easter in self's year
521
- Date.easter(self.year)
521
+ Date.easter(year)
522
522
  end
523
523
 
524
524
  def easter?
525
525
  # Am I Easter?
526
- self == self.easter_this_year
526
+ self == easter_this_year
527
527
  end
528
528
 
529
529
  def nth_wday_in_month?(n, wday, month)
@@ -538,16 +538,16 @@ class Date
538
538
  #######################################################
539
539
  def fed_fixed_holiday?
540
540
  # Fixed-date holidays on weekdays
541
- if self.mon == 1 && self.mday == 1
541
+ if mon == 1 && mday == 1
542
542
  # New Years (January 1),
543
543
  true
544
- elsif self.mon == 7 && self.mday == 4
544
+ elsif mon == 7 && mday == 4
545
545
  # Independence Day (July 4),
546
546
  true
547
- elsif self.mon == 11 && self.mday == 11
547
+ elsif mon == 11 && mday == 11
548
548
  # Veterans Day (November 11),
549
549
  true
550
- elsif self.mon == 12 && self.mday == 25
550
+ elsif mon == 12 && mday == 25
551
551
  # Christmas (December 25), and
552
552
  true
553
553
  else
@@ -560,25 +560,25 @@ class Date
560
560
  # rigged to fall on Monday except Thanksgiving
561
561
 
562
562
  # No moveable feasts in certain months
563
- if [ 3, 4, 6, 7, 8, 12 ].include?(self.month)
563
+ if [ 3, 4, 6, 7, 8, 12 ].include?(month)
564
564
  false
565
- elsif self.wday == 1
565
+ elsif monday?
566
566
  moveable_mondays = []
567
567
  # MLK's Birthday (Third Monday in Jan)
568
- moveable_mondays << self.nth_wday_in_month?(3, 1, 1)
568
+ moveable_mondays << nth_wday_in_month?(3, 1, 1)
569
569
  # Washington's Birthday (Third Monday in Feb)
570
- moveable_mondays << self.nth_wday_in_month?(3, 1, 2)
570
+ moveable_mondays << nth_wday_in_month?(3, 1, 2)
571
571
  # Memorial Day (Last Monday in May)
572
- moveable_mondays << self.nth_wday_in_month?(-1, 1, 5)
572
+ moveable_mondays << nth_wday_in_month?(-1, 1, 5)
573
573
  # Labor Day (First Monday in Sep)
574
- moveable_mondays << self.nth_wday_in_month?(1, 1, 9)
574
+ moveable_mondays << nth_wday_in_month?(1, 1, 9)
575
575
  # Columbus Day (Second Monday in Oct)
576
- moveable_mondays << self.nth_wday_in_month?(2, 1, 10)
576
+ moveable_mondays << nth_wday_in_month?(2, 1, 10)
577
577
  # Other Mondays
578
578
  moveable_mondays.any?
579
- elsif self.wday == 4
579
+ elsif thursday?
580
580
  # Thanksgiving Day (Fourth Thur in Nov)
581
- self.nth_wday_in_month?(4, 4, 11)
581
+ nth_wday_in_month?(4, 4, 11)
582
582
  else
583
583
  false
584
584
  end
@@ -586,23 +586,23 @@ class Date
586
586
 
587
587
  def fed_holiday?
588
588
  # All Saturdays and Sundays are "holidays"
589
- return true if self.weekend?
589
+ return true if weekend?
590
590
 
591
591
  # Some days are holidays by executive decree
592
592
  return true if FED_DECREED_HOLIDAYS.include?(self)
593
593
 
594
594
  # Is self a fixed holiday
595
- return true if (self.fed_fixed_holiday? || self.fed_moveable_feast?)
595
+ return true if (fed_fixed_holiday? || fed_moveable_feast?)
596
596
 
597
- if self.wday == 5 and self.month == 12 and self.day == 26
597
+ if friday? && month == 12 && day == 26
598
598
  # If Christmas falls on a Thursday, apparently, the Friday after is
599
599
  # treated as a holiday as well. See 2003, 2008, for example.
600
600
  true
601
- elsif self.wday == 5
601
+ elsif friday?
602
602
  # A Friday is a holiday if a fixed-date holiday
603
603
  # would fall on the following Saturday
604
604
  (self + 1).fed_fixed_holiday? || (self + 1).fed_moveable_feast?
605
- elsif self.wday == 1
605
+ elsif monday?
606
606
  # A Monday is a holiday if a fixed-date holiday
607
607
  # would fall on the preceding Sunday
608
608
  (self - 1).fed_fixed_holiday? || (self - 1).fed_moveable_feast?
@@ -632,13 +632,13 @@ class Date
632
632
 
633
633
  def nyse_fixed_holiday?
634
634
  # Fixed-date holidays
635
- if self.mon == 1 && self.mday == 1
635
+ if mon == 1 && mday == 1
636
636
  # New Years (January 1),
637
637
  true
638
- elsif self.mon == 7 && self.mday == 4
638
+ elsif mon == 7 && mday == 4
639
639
  # Independence Day (July 4),
640
640
  true
641
- elsif self.mon == 12 && self.mday == 25
641
+ elsif mon == 12 && mday == 25
642
642
  # Christmas (December 25), and
643
643
  true
644
644
  else
@@ -651,7 +651,7 @@ class Date
651
651
  # rigged to fall on Monday except Thanksgiving
652
652
 
653
653
  # No moveable feasts in certain months
654
- return false if [ 6, 7, 8, 10, 12 ].include?(self.month)
654
+ return false if [ 6, 7, 8, 10, 12 ].include?(month)
655
655
 
656
656
  case month
657
657
  when 1
@@ -665,7 +665,7 @@ class Date
665
665
  : nth_wday_in_month?(3, 1, 2))
666
666
  when 3, 4
667
667
  # Good Friday
668
- if self.wday != 5
668
+ if !friday?
669
669
  false
670
670
  else
671
671
  # Good Friday, the Friday before Easter, except certain years
@@ -685,7 +685,7 @@ class Date
685
685
  # Columbus Day (Oct 12) 1909--1953
686
686
  year >= 1909 && year <= 1953 && day == 12
687
687
  when 11
688
- if wday == 2
688
+ if tuesday?
689
689
  # Election Day. Until 1968 all Election Days. From 1972 to 1980
690
690
  # Election Day in presidential years only. Election Day is the first
691
691
  # Tuesday after the first Monday in November.
@@ -698,7 +698,7 @@ class Date
698
698
  else
699
699
  false
700
700
  end
701
- elsif wday == 4
701
+ elsif thursday?
702
702
  # Historically Thanksgiving (NYSE closed all day) had been declared to be
703
703
  # the last Thursday in November until 1938;
704
704
  # the next-to-last Thursday in November from 1939 to 1941
@@ -751,7 +751,7 @@ class Date
751
751
  true
752
752
  when (Date.parse('1968-06-12')..Date.parse('1968-12-31'))
753
753
  # Paperwork crisis (closed on Wednesdays if no other holiday in week)
754
- wday == 3 && (self - 2).nyse_workday? && (self - 1).nyse_workday? &&
754
+ wednesday? && (self - 2).nyse_workday? && (self - 1).nyse_workday? &&
755
755
  (self + 1).nyse_workday? && (self + 2).nyse_workday?
756
756
  when Date.parse('1969-02-10')
757
757
  # Heavy snow
@@ -796,20 +796,26 @@ class Date
796
796
 
797
797
  def nyse_holiday?
798
798
  # All Saturdays and Sundays are "holidays"
799
- return true if self.weekend?
799
+ return true if weekend?
800
800
 
801
801
  # Is self a fixed holiday
802
- return true if self.nyse_fixed_holiday? || self.nyse_moveable_feast?
802
+ return true if nyse_fixed_holiday? || nyse_moveable_feast?
803
803
 
804
804
  return true if nyse_special_holiday
805
805
 
806
- if self.wday == 5
807
- # A Friday is a holiday if a fixed-date holiday
808
- # would fall on the following Saturday
809
- (self + 1).nyse_fixed_holiday? || (self + 1).nyse_moveable_feast?
810
- elsif self.wday == 1
811
- # A Monday is a holiday if a fixed-date holiday
812
- # would fall on the preceding Sunday
806
+ if friday? && (self >= Date.parse('1959-07-03'))
807
+ # A Friday is a holiday if a holiday would fall on the following
808
+ # Saturday. The rule does not apply if the Friday "ends a monthly or
809
+ # yearly accounting period." Adopted July 3, 1959. E.g, December 31,
810
+ # 2010, fell on a Friday, so New Years was on Saturday, but the NYSE
811
+ # opened because it ended a yearly accounting period. I believe 12/31
812
+ # is the only date to which the exception can apply since only New
813
+ # Year's can fall on the first of the month.
814
+ !end_of_quarter? &&
815
+ ((self + 1).nyse_fixed_holiday? || (self + 1).nyse_moveable_feast?)
816
+ elsif monday?
817
+ # A Monday is a holiday if a holiday would fall on the
818
+ # preceding Sunday. This has apparently always been the rule.
813
819
  (self - 1).nyse_fixed_holiday? || (self - 1).nyse_moveable_feast?
814
820
  else
815
821
  false
@@ -817,11 +823,11 @@ class Date
817
823
  end
818
824
 
819
825
  def fed_workday?
820
- !self.fed_holiday?
826
+ !fed_holiday?
821
827
  end
822
828
 
823
829
  def nyse_workday?
824
- !self.nyse_holiday?
830
+ !nyse_holiday?
825
831
  end
826
832
 
827
833
  def add_fed_business_days(n)
@@ -839,11 +845,11 @@ class Date
839
845
  end
840
846
 
841
847
  def next_fed_workday
842
- self.add_fed_business_days(1)
848
+ add_fed_business_days(1)
843
849
  end
844
850
 
845
851
  def prior_fed_workday
846
- self.add_fed_business_days(-1)
852
+ add_fed_business_days(-1)
847
853
  end
848
854
 
849
855
  def add_nyse_business_days(n)
@@ -861,10 +867,10 @@ class Date
861
867
  end
862
868
 
863
869
  def next_nyse_workday
864
- self.add_nyse_business_days(1)
870
+ add_nyse_business_days(1)
865
871
  end
866
872
 
867
873
  def prior_nyse_workday
868
- self.add_nyse_business_days(-1)
874
+ add_nyse_business_days(-1)
869
875
  end
870
876
  end
@@ -1,7 +1,7 @@
1
1
  module FatCore
2
2
  MAJOR = 0
3
3
  MINOR = 2
4
- PATCH = 6
4
+ PATCH = 7
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fat_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-21 00:00:00.000000000 Z
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov