fat_core 0.2.6 → 0.2.7
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 +4 -4
- data/lib/fat_core/date.rb +63 -57
- data/lib/fat_core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 864810f594f41bc38df56e4968c5c945c95a9fdf
|
4
|
+
data.tar.gz: 6aae1699bfce083fa87f859b4842ec2f3f666cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
301
|
+
beginning_of_year == self
|
302
302
|
end
|
303
303
|
|
304
304
|
def end_of_year?
|
305
|
-
|
305
|
+
end_of_year == self
|
306
306
|
end
|
307
307
|
|
308
308
|
def beginning_of_quarter?
|
309
|
-
|
309
|
+
beginning_of_quarter == self
|
310
310
|
end
|
311
311
|
|
312
312
|
def end_of_quarter?
|
313
|
-
|
313
|
+
end_of_quarter == self
|
314
314
|
end
|
315
315
|
|
316
316
|
def beginning_of_bimonth?
|
317
317
|
month % 2 == 1 &&
|
318
|
-
|
318
|
+
beginning_of_month == self
|
319
319
|
end
|
320
320
|
|
321
321
|
def end_of_bimonth?
|
322
322
|
month % 2 == 0 &&
|
323
|
-
|
323
|
+
end_of_month == self
|
324
324
|
end
|
325
325
|
|
326
326
|
def beginning_of_month?
|
327
|
-
|
327
|
+
beginning_of_month == self
|
328
328
|
end
|
329
329
|
|
330
330
|
def end_of_month?
|
331
|
-
|
331
|
+
end_of_month == self
|
332
332
|
end
|
333
333
|
|
334
334
|
def beginning_of_semimonth?
|
335
|
-
|
335
|
+
beginning_of_semimonth == self
|
336
336
|
end
|
337
337
|
|
338
338
|
def end_of_semimonth?
|
339
|
-
|
339
|
+
end_of_semimonth == self
|
340
340
|
end
|
341
341
|
|
342
342
|
def beginning_of_biweek?
|
343
|
-
|
343
|
+
beginning_of_biweek == self
|
344
344
|
end
|
345
345
|
|
346
346
|
def end_of_biweek?
|
347
|
-
|
347
|
+
end_of_biweek == self
|
348
348
|
end
|
349
349
|
|
350
350
|
def beginning_of_week?
|
351
|
-
|
351
|
+
beginning_of_week == self
|
352
352
|
end
|
353
353
|
|
354
354
|
def end_of_week?
|
355
|
-
|
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(
|
521
|
+
Date.easter(year)
|
522
522
|
end
|
523
523
|
|
524
524
|
def easter?
|
525
525
|
# Am I Easter?
|
526
|
-
self ==
|
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
|
541
|
+
if mon == 1 && mday == 1
|
542
542
|
# New Years (January 1),
|
543
543
|
true
|
544
|
-
elsif
|
544
|
+
elsif mon == 7 && mday == 4
|
545
545
|
# Independence Day (July 4),
|
546
546
|
true
|
547
|
-
elsif
|
547
|
+
elsif mon == 11 && mday == 11
|
548
548
|
# Veterans Day (November 11),
|
549
549
|
true
|
550
|
-
elsif
|
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?(
|
563
|
+
if [ 3, 4, 6, 7, 8, 12 ].include?(month)
|
564
564
|
false
|
565
|
-
elsif
|
565
|
+
elsif monday?
|
566
566
|
moveable_mondays = []
|
567
567
|
# MLK's Birthday (Third Monday in Jan)
|
568
|
-
moveable_mondays <<
|
568
|
+
moveable_mondays << nth_wday_in_month?(3, 1, 1)
|
569
569
|
# Washington's Birthday (Third Monday in Feb)
|
570
|
-
moveable_mondays <<
|
570
|
+
moveable_mondays << nth_wday_in_month?(3, 1, 2)
|
571
571
|
# Memorial Day (Last Monday in May)
|
572
|
-
moveable_mondays <<
|
572
|
+
moveable_mondays << nth_wday_in_month?(-1, 1, 5)
|
573
573
|
# Labor Day (First Monday in Sep)
|
574
|
-
moveable_mondays <<
|
574
|
+
moveable_mondays << nth_wday_in_month?(1, 1, 9)
|
575
575
|
# Columbus Day (Second Monday in Oct)
|
576
|
-
moveable_mondays <<
|
576
|
+
moveable_mondays << nth_wday_in_month?(2, 1, 10)
|
577
577
|
# Other Mondays
|
578
578
|
moveable_mondays.any?
|
579
|
-
elsif
|
579
|
+
elsif thursday?
|
580
580
|
# Thanksgiving Day (Fourth Thur in Nov)
|
581
|
-
|
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
|
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 (
|
595
|
+
return true if (fed_fixed_holiday? || fed_moveable_feast?)
|
596
596
|
|
597
|
-
if
|
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
|
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
|
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
|
635
|
+
if mon == 1 && mday == 1
|
636
636
|
# New Years (January 1),
|
637
637
|
true
|
638
|
-
elsif
|
638
|
+
elsif mon == 7 && mday == 4
|
639
639
|
# Independence Day (July 4),
|
640
640
|
true
|
641
|
-
elsif
|
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?(
|
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
|
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
|
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
|
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
|
-
|
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
|
799
|
+
return true if weekend?
|
800
800
|
|
801
801
|
# Is self a fixed holiday
|
802
|
-
return true if
|
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
|
807
|
-
# A Friday is a holiday if a
|
808
|
-
#
|
809
|
-
|
810
|
-
|
811
|
-
#
|
812
|
-
#
|
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
|
-
!
|
826
|
+
!fed_holiday?
|
821
827
|
end
|
822
828
|
|
823
829
|
def nyse_workday?
|
824
|
-
!
|
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
|
-
|
848
|
+
add_fed_business_days(1)
|
843
849
|
end
|
844
850
|
|
845
851
|
def prior_fed_workday
|
846
|
-
|
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
|
-
|
870
|
+
add_nyse_business_days(1)
|
865
871
|
end
|
866
872
|
|
867
873
|
def prior_nyse_workday
|
868
|
-
|
874
|
+
add_nyse_business_days(-1)
|
869
875
|
end
|
870
876
|
end
|
data/lib/fat_core/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|