increments-schedule 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/increments/schedule.rb +17 -13
- data/lib/increments/schedule/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ed9a60f8d0e1e98939183fb197dbd40e50bf261
|
4
|
+
data.tar.gz: 27cf83e11edd682076f325f6112b9c06b14d3e69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b41c6f417c1fc3c5dcb9125e28b1328d118979fffe8940810b57586e5378bb9803aac7af5f44afe2766e913953e7adbf90af039f75edd01906473556082092b
|
7
|
+
data.tar.gz: e096e1f259d6ba2c5ebedecdd089326468aa900b1842156e2ae21b6ae35c741c5cda114640d0d3622ecc61b7c3033bead5b897c6fb30edbe0d51b0e27bb65f29
|
data/lib/increments/schedule.rb
CHANGED
@@ -5,9 +5,6 @@ module Increments
|
|
5
5
|
module Schedule
|
6
6
|
extend self # rubocop:disable ModuleFunction
|
7
7
|
|
8
|
-
INFINITY_FUTURE = Date.new(10_000, 1, 1)
|
9
|
-
INFINITY_PAST = Date.new(0, 1, 1)
|
10
|
-
|
11
8
|
def foundation_anniversary?(date = Date.today)
|
12
9
|
date.month == 2 && date.day == 29
|
13
10
|
end
|
@@ -47,11 +44,11 @@ module Increments
|
|
47
44
|
def winter_vacation?(date = Date.today)
|
48
45
|
case date.month
|
49
46
|
when 1
|
50
|
-
|
51
|
-
date <=
|
47
|
+
return true if date.day <= 3
|
48
|
+
date <= ExtendedDate.new(date.year, 1, 1).find_next(&:sunday?)
|
52
49
|
when 12
|
53
|
-
|
54
|
-
date >=
|
50
|
+
return true if date.day >= 28
|
51
|
+
date >= ExtendedDate.new(date.year, 12, 31).find_previous(&:saturday?)
|
55
52
|
else
|
56
53
|
false
|
57
54
|
end
|
@@ -71,13 +68,20 @@ module Increments
|
|
71
68
|
end
|
72
69
|
end
|
73
70
|
|
74
|
-
|
71
|
+
class ExtendedDate < Date
|
72
|
+
INFINITY_FUTURE = Date.new(10_000, 1, 1)
|
73
|
+
INFINITY_PAST = Date.new(0, 1, 1)
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
def find_next
|
76
|
+
upto(INFINITY_FUTURE) do |date|
|
77
|
+
break date if yield date
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def find_previous
|
82
|
+
downto(INFINITY_PAST) do |date|
|
83
|
+
break date if yield date
|
84
|
+
end
|
81
85
|
end
|
82
86
|
end
|
83
87
|
end
|