biz 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/biz/day_time.rb +36 -15
- data/lib/biz/time.rb +3 -2
- data/lib/biz/version.rb +1 -1
- data/lib/biz/week_time/abstract.rb +1 -0
- data/lib/biz/week_time/end.rb +1 -1
- data/lib/biz/week_time/start.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: 1d05e74b61bbcd76562d54907d90b90252579da8
|
4
|
+
data.tar.gz: b30af6939b9302e91d00e10289da02ef4ea87bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce1f8adb07629077dd1a6f9d9f9f297a993792de30d362960ea2b690cee778c6f320f1ffdcf75ad5196a0dbb0eaea086a3c5d4cc51926475b3aa8aa768c7db26
|
7
|
+
data.tar.gz: e78efec99aeb0175351750d4354930e061961287dacfd00c20b6a7fb49bd8c46d7651b337d31e2722e70e4d101a07b3059b26512451dfa6785ce5f3c48dea943
|
data/README.md
CHANGED
data/lib/biz/day_time.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
module Biz
|
2
2
|
class DayTime
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
module Timestamp
|
5
|
+
|
6
|
+
FORMAT = '%02d:%02d'
|
7
|
+
PATTERN = /\A(?<hour>\d{2}):(?<minute>\d{2})(:?(?<second>\d{2}))?\Z/
|
8
|
+
|
9
|
+
end
|
6
10
|
|
7
11
|
include Comparable
|
8
12
|
|
@@ -11,16 +15,24 @@ module Biz
|
|
11
15
|
class << self
|
12
16
|
|
13
17
|
def from_time(time)
|
14
|
-
new(time.hour * Time::
|
18
|
+
new(time.hour * Time::HOUR + time.min * Time::MINUTE + time.sec)
|
19
|
+
end
|
20
|
+
|
21
|
+
def from_minute(minute)
|
22
|
+
new(minute * Time::MINUTE)
|
15
23
|
end
|
16
24
|
|
17
25
|
def from_hour(hour)
|
18
|
-
new(hour * Time::
|
26
|
+
new(hour * Time::HOUR)
|
19
27
|
end
|
20
28
|
|
21
29
|
def from_timestamp(timestamp)
|
22
|
-
timestamp.match(
|
23
|
-
new(
|
30
|
+
timestamp.match(Timestamp::PATTERN) { |match|
|
31
|
+
new(
|
32
|
+
match[:hour].to_i * Time::HOUR +
|
33
|
+
match[:minute].to_i * Time::MINUTE +
|
34
|
+
match[:second].to_i
|
35
|
+
)
|
24
36
|
}
|
25
37
|
end
|
26
38
|
|
@@ -42,29 +54,37 @@ module Biz
|
|
42
54
|
|
43
55
|
end
|
44
56
|
|
45
|
-
attr_reader :
|
57
|
+
attr_reader :day_second
|
46
58
|
|
47
59
|
delegate strftime: :day_time
|
48
60
|
|
49
61
|
delegate %i[
|
50
62
|
to_i
|
51
63
|
to_int
|
52
|
-
] => :
|
64
|
+
] => :day_second
|
53
65
|
|
54
|
-
def initialize(
|
55
|
-
@
|
66
|
+
def initialize(day_second)
|
67
|
+
@day_second = Integer(day_second)
|
56
68
|
end
|
57
69
|
|
58
70
|
def hour
|
59
|
-
|
71
|
+
day_second / Time::HOUR
|
60
72
|
end
|
61
73
|
|
62
74
|
def minute
|
63
|
-
|
75
|
+
day_second % Time::HOUR / Time::MINUTE
|
76
|
+
end
|
77
|
+
|
78
|
+
def second
|
79
|
+
day_second % Time::MINUTE
|
80
|
+
end
|
81
|
+
|
82
|
+
def day_minute
|
83
|
+
hour * Time::MINUTES_IN_HOUR + minute
|
64
84
|
end
|
65
85
|
|
66
86
|
def timestamp
|
67
|
-
format(
|
87
|
+
format(Timestamp::FORMAT, hour, minute)
|
68
88
|
end
|
69
89
|
|
70
90
|
def coerce(other)
|
@@ -76,7 +96,7 @@ module Biz
|
|
76
96
|
def <=>(other)
|
77
97
|
return nil unless other.respond_to?(:to_i)
|
78
98
|
|
79
|
-
|
99
|
+
day_second <=> other.to_i
|
80
100
|
end
|
81
101
|
|
82
102
|
private
|
@@ -87,7 +107,8 @@ module Biz
|
|
87
107
|
Date::EPOCH.month,
|
88
108
|
Date::EPOCH.mday,
|
89
109
|
hour,
|
90
|
-
minute
|
110
|
+
minute,
|
111
|
+
second
|
91
112
|
)
|
92
113
|
end
|
93
114
|
|
data/lib/biz/time.rb
CHANGED
@@ -33,12 +33,13 @@ module Biz
|
|
33
33
|
date.month,
|
34
34
|
date.mday,
|
35
35
|
day_time.hour,
|
36
|
-
day_time.minute
|
36
|
+
day_time.minute,
|
37
|
+
day_time.second
|
37
38
|
),
|
38
39
|
true
|
39
40
|
)
|
40
41
|
rescue TZInfo::PeriodNotFound
|
41
|
-
on_date(date, DayTime.new(day_time.
|
42
|
+
on_date(date, DayTime.new(day_time.day_second + HOUR))
|
42
43
|
end
|
43
44
|
|
44
45
|
def during_week(week, week_time)
|
data/lib/biz/version.rb
CHANGED
data/lib/biz/week_time/end.rb
CHANGED
data/lib/biz/week_time/start.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Little
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: abstract_type
|