tempora 0.1.0 → 0.1.1
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/month.rb +6 -6
- data/lib/quarter.rb +6 -6
- data/lib/tempora/version.rb +1 -1
- data/lib/timeperiod.rb +5 -5
- data/lib/week.rb +4 -4
- data/lib/year.rb +6 -6
- 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: 459b4b52f06524a60b3a661aea7d7abdaff9893f92d1396b628e20003e26b985
|
4
|
+
data.tar.gz: 32bfd35efcbbb4342de00d19c1e08df914dcf85472ff576f745630d9d143d0dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8eb1686ef5c168d8eb95a415012428e07703d2c531b8a424ab8fc4e2612f283c5295eb83a1fc00bb91d757e01262836a9cc9bfc1fcdc32f1a2ed30acebe8298
|
7
|
+
data.tar.gz: 6cdca41e418c828b85c31fb5140286b5585a49a776618d2d813bbd19a875d5c48657d80617a0de7d5da0420613fedeaf419d780c86a59acdc626bc56c545e8a5
|
data/lib/month.rb
CHANGED
@@ -15,27 +15,27 @@ class Month
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def id(seperator="-")
|
18
|
-
"#{
|
18
|
+
"#{year}#{seperator}#{number.to_s.rjust(2, '0')}"
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_s
|
22
|
-
"#{month_name} #{
|
22
|
+
"#{month_name} #{year}"
|
23
23
|
end
|
24
24
|
|
25
25
|
def month_name
|
26
|
-
Date::MONTHNAMES[
|
26
|
+
Date::MONTHNAMES[number]
|
27
27
|
end
|
28
28
|
|
29
29
|
def month_abbr
|
30
|
-
Date::ABBR_MONTHNAMES[
|
30
|
+
Date::ABBR_MONTHNAMES[number]
|
31
31
|
end
|
32
32
|
|
33
33
|
def next
|
34
|
-
self.class.from(
|
34
|
+
self.class.from(start_date.next_month) # @start_date >> 1
|
35
35
|
end
|
36
36
|
|
37
37
|
def prev
|
38
|
-
self.class.from(
|
38
|
+
self.class.from(start_date.prev_month) # @start_date << 1
|
39
39
|
end
|
40
40
|
|
41
41
|
def weeks
|
data/lib/quarter.rb
CHANGED
@@ -17,30 +17,30 @@ class Quarter
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def id(seperator="-")
|
20
|
-
"#{
|
20
|
+
"#{year}#{seperator}Q#{number}"
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_s
|
24
|
-
"Q#{
|
24
|
+
"Q#{number} #{year}"
|
25
25
|
end
|
26
26
|
|
27
27
|
def next
|
28
|
-
self.class.from(
|
28
|
+
self.class.from(start_date >> 3)
|
29
29
|
end
|
30
30
|
|
31
31
|
def prev
|
32
|
-
self.class.from(
|
32
|
+
self.class.from(start_date << 3)
|
33
33
|
end
|
34
34
|
|
35
35
|
alias_method :succ, :next
|
36
36
|
alias_method :pred, :prev
|
37
37
|
|
38
38
|
def months
|
39
|
-
Month.from(
|
39
|
+
Month.from(start_date)..Month.from(end_date)
|
40
40
|
end
|
41
41
|
|
42
42
|
def weeks
|
43
|
-
Week.from(
|
43
|
+
Week.from(start_date)..Week.from(end_date)
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
data/lib/tempora/version.rb
CHANGED
data/lib/timeperiod.rb
CHANGED
@@ -6,11 +6,11 @@ module TimePeriod
|
|
6
6
|
attr_reader :start_date, :end_date, :year, :number
|
7
7
|
|
8
8
|
def range
|
9
|
-
|
9
|
+
start_date..end_date
|
10
10
|
end
|
11
11
|
|
12
12
|
def duration
|
13
|
-
(
|
13
|
+
(end_date - start_date).to_i + 1
|
14
14
|
end
|
15
15
|
|
16
16
|
def days
|
@@ -32,14 +32,14 @@ module TimePeriod
|
|
32
32
|
def intersection(other)
|
33
33
|
return nil unless overlaps?(other)
|
34
34
|
|
35
|
-
new_start = [
|
36
|
-
new_end = [
|
35
|
+
new_start = [start_date, other.start_date].max
|
36
|
+
new_end = [end_date, other.end_date].min
|
37
37
|
|
38
38
|
self.class.new(new_start, new_end)
|
39
39
|
end
|
40
40
|
|
41
41
|
def <=>(other)
|
42
|
-
|
42
|
+
start_date <=> other.start_date
|
43
43
|
end
|
44
44
|
|
45
45
|
alias_method :begin, :start_date
|
data/lib/week.rb
CHANGED
@@ -14,19 +14,19 @@ class Week
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def id(seperator="-")
|
17
|
-
"#{
|
17
|
+
"#{year}#{seperator}W#{format('%02d', number)}"
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_s
|
21
|
-
"Week #{
|
21
|
+
"Week #{number}, #{year}"
|
22
22
|
end
|
23
23
|
|
24
24
|
def next
|
25
|
-
self.class.from(
|
25
|
+
self.class.from(start_date + 7)
|
26
26
|
end
|
27
27
|
|
28
28
|
def prev
|
29
|
-
self.class.from(
|
29
|
+
self.class.from(start_date - 7)
|
30
30
|
end
|
31
31
|
|
32
32
|
alias_method :succ, :next
|
data/lib/year.rb
CHANGED
@@ -15,27 +15,27 @@ class Year
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def id
|
18
|
-
|
18
|
+
year
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_s
|
22
|
-
|
22
|
+
year.to_s
|
23
23
|
end
|
24
24
|
|
25
25
|
def next
|
26
|
-
self.class.new(
|
26
|
+
self.class.new(year + 1)
|
27
27
|
end
|
28
28
|
|
29
29
|
def prev
|
30
|
-
self.class.new(
|
30
|
+
self.class.new(year - 1)
|
31
31
|
end
|
32
32
|
|
33
33
|
def months
|
34
|
-
Month.new(
|
34
|
+
Month.new(year, 1)..Month.new(year, 12)
|
35
35
|
end
|
36
36
|
|
37
37
|
def weeks
|
38
|
-
Week.
|
38
|
+
Week.from(start_date)..Week.from(end_date)
|
39
39
|
end
|
40
40
|
|
41
41
|
alias_method :succ, :next
|