time_ext 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.md +69 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/doc/Time.html +2277 -0
- data/doc/_index.html +94 -0
- data/doc/class_list.html +36 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +50 -0
- data/doc/css/style.css +277 -0
- data/doc/file.README.html +105 -0
- data/doc/file_list.html +38 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +105 -0
- data/doc/js/app.js +138 -0
- data/doc/js/full_list.js +117 -0
- data/doc/js/jquery.js +19 -0
- data/doc/method_list.html +291 -0
- data/doc/top-level-namespace.html +88 -0
- data/lib/time/ext.rb +1 -0
- data/lib/time_ext/time.rb +191 -0
- data/lib/time_ext.rb +3 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/time_ext_spec.rb +285 -0
- metadata +140 -0
@@ -0,0 +1,291 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
|
7
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
9
|
+
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
10
|
+
<base id="base_target" target="_parent" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<script type="text/javascript" charset="utf-8">
|
14
|
+
if (window.top.frames.main) {
|
15
|
+
document.getElementById('base_target').target = 'main';
|
16
|
+
document.body.className = 'frames';
|
17
|
+
}
|
18
|
+
</script>
|
19
|
+
<div id="content">
|
20
|
+
<h1 id="full_list_header">Method List</h1>
|
21
|
+
<div id="nav">
|
22
|
+
<a target="_self" href="class_list.html">Classes</a> |
|
23
|
+
<a target="_self" href="method_list.html">Methods</a> |
|
24
|
+
<a target="_self" href="file_list.html">Files</a>
|
25
|
+
</div>
|
26
|
+
<div id="search">Search: <input type="text" /></div>
|
27
|
+
|
28
|
+
<ul id="full_list" class="methods">
|
29
|
+
|
30
|
+
|
31
|
+
<li class="r1 ">
|
32
|
+
<a href="Time.html#beginning_of_hour-instance_method" title="Time#beginning_of_hour (method)">#beginning_of_hour</a>
|
33
|
+
|
34
|
+
<small>Time</small>
|
35
|
+
|
36
|
+
</li>
|
37
|
+
|
38
|
+
|
39
|
+
<li class="r2 ">
|
40
|
+
<a href="Time.html#beginning_of_minute-instance_method" title="Time#beginning_of_minute (method)">#beginning_of_minute</a>
|
41
|
+
|
42
|
+
<small>Time</small>
|
43
|
+
|
44
|
+
</li>
|
45
|
+
|
46
|
+
|
47
|
+
<li class="r1 ">
|
48
|
+
<a href="Time.html#beginning_of_second-instance_method" title="Time#beginning_of_second (method)">#beginning_of_second</a>
|
49
|
+
|
50
|
+
<small>Time</small>
|
51
|
+
|
52
|
+
</li>
|
53
|
+
|
54
|
+
|
55
|
+
<li class="r2 ">
|
56
|
+
<a href="Time.html#ceil-instance_method" title="Time#ceil (method)">#ceil</a>
|
57
|
+
|
58
|
+
<small>Time</small>
|
59
|
+
|
60
|
+
</li>
|
61
|
+
|
62
|
+
|
63
|
+
<li class="r1 ">
|
64
|
+
<a href="Time.html#common_year_days_in_month-instance_method" title="Time#common_year_days_in_month (method)">#common_year_days_in_month</a>
|
65
|
+
|
66
|
+
<small>Time</small>
|
67
|
+
|
68
|
+
</li>
|
69
|
+
|
70
|
+
|
71
|
+
<li class="r2 ">
|
72
|
+
<a href="Time.html#days_ago-instance_method" title="Time#days_ago (method)">#days_ago</a>
|
73
|
+
|
74
|
+
<small>Time</small>
|
75
|
+
|
76
|
+
</li>
|
77
|
+
|
78
|
+
|
79
|
+
<li class="r1 ">
|
80
|
+
<a href="Time.html#days_into_week-instance_method" title="Time#days_into_week (method)">#days_into_week</a>
|
81
|
+
|
82
|
+
<small>Time</small>
|
83
|
+
|
84
|
+
</li>
|
85
|
+
|
86
|
+
|
87
|
+
<li class="r2 ">
|
88
|
+
<a href="Time.html#days_since-instance_method" title="Time#days_since (method)">#days_since</a>
|
89
|
+
|
90
|
+
<small>Time</small>
|
91
|
+
|
92
|
+
</li>
|
93
|
+
|
94
|
+
|
95
|
+
<li class="r1 ">
|
96
|
+
<a href="Time.html#end_of_hour-instance_method" title="Time#end_of_hour (method)">#end_of_hour</a>
|
97
|
+
|
98
|
+
<small>Time</small>
|
99
|
+
|
100
|
+
</li>
|
101
|
+
|
102
|
+
|
103
|
+
<li class="r2 ">
|
104
|
+
<a href="Time.html#end_of_minute-instance_method" title="Time#end_of_minute (method)">#end_of_minute</a>
|
105
|
+
|
106
|
+
<small>Time</small>
|
107
|
+
|
108
|
+
</li>
|
109
|
+
|
110
|
+
|
111
|
+
<li class="r1 ">
|
112
|
+
<a href="Time.html#end_of_second-instance_method" title="Time#end_of_second (method)">#end_of_second</a>
|
113
|
+
|
114
|
+
<small>Time</small>
|
115
|
+
|
116
|
+
</li>
|
117
|
+
|
118
|
+
|
119
|
+
<li class="r2 ">
|
120
|
+
<a href="Time.html#floor-instance_method" title="Time#floor (method)">#floor</a>
|
121
|
+
|
122
|
+
<small>Time</small>
|
123
|
+
|
124
|
+
</li>
|
125
|
+
|
126
|
+
|
127
|
+
<li class="r1 ">
|
128
|
+
<a href="Time.html#hours_ago-instance_method" title="Time#hours_ago (method)">#hours_ago</a>
|
129
|
+
|
130
|
+
<small>Time</small>
|
131
|
+
|
132
|
+
</li>
|
133
|
+
|
134
|
+
|
135
|
+
<li class="r2 ">
|
136
|
+
<a href="Time.html#hours_since-instance_method" title="Time#hours_since (method)">#hours_since</a>
|
137
|
+
|
138
|
+
<small>Time</small>
|
139
|
+
|
140
|
+
</li>
|
141
|
+
|
142
|
+
|
143
|
+
<li class="r1 ">
|
144
|
+
<a href="Time.html#minutes_ago-instance_method" title="Time#minutes_ago (method)">#minutes_ago</a>
|
145
|
+
|
146
|
+
<small>Time</small>
|
147
|
+
|
148
|
+
</li>
|
149
|
+
|
150
|
+
|
151
|
+
<li class="r2 ">
|
152
|
+
<a href="Time.html#minutes_since-instance_method" title="Time#minutes_since (method)">#minutes_since</a>
|
153
|
+
|
154
|
+
<small>Time</small>
|
155
|
+
|
156
|
+
</li>
|
157
|
+
|
158
|
+
|
159
|
+
<li class="r1 ">
|
160
|
+
<a href="Time.html#next_day-instance_method" title="Time#next_day (method)">#next_day</a>
|
161
|
+
|
162
|
+
<small>Time</small>
|
163
|
+
|
164
|
+
</li>
|
165
|
+
|
166
|
+
|
167
|
+
<li class="r2 ">
|
168
|
+
<a href="Time.html#next_hour-instance_method" title="Time#next_hour (method)">#next_hour</a>
|
169
|
+
|
170
|
+
<small>Time</small>
|
171
|
+
|
172
|
+
</li>
|
173
|
+
|
174
|
+
|
175
|
+
<li class="r1 ">
|
176
|
+
<a href="Time.html#next_minute-instance_method" title="Time#next_minute (method)">#next_minute</a>
|
177
|
+
|
178
|
+
<small>Time</small>
|
179
|
+
|
180
|
+
</li>
|
181
|
+
|
182
|
+
|
183
|
+
<li class="r2 ">
|
184
|
+
<a href="Time.html#next_quarter-instance_method" title="Time#next_quarter (method)">#next_quarter</a>
|
185
|
+
|
186
|
+
<small>Time</small>
|
187
|
+
|
188
|
+
</li>
|
189
|
+
|
190
|
+
|
191
|
+
<li class="r1 ">
|
192
|
+
<a href="Time.html#next_second-instance_method" title="Time#next_second (method)">#next_second</a>
|
193
|
+
|
194
|
+
<small>Time</small>
|
195
|
+
|
196
|
+
</li>
|
197
|
+
|
198
|
+
|
199
|
+
<li class="r2 ">
|
200
|
+
<a href="Time.html#prev_day-instance_method" title="Time#prev_day (method)">#prev_day</a>
|
201
|
+
|
202
|
+
<small>Time</small>
|
203
|
+
|
204
|
+
</li>
|
205
|
+
|
206
|
+
|
207
|
+
<li class="r1 ">
|
208
|
+
<a href="Time.html#prev_hour-instance_method" title="Time#prev_hour (method)">#prev_hour</a>
|
209
|
+
|
210
|
+
<small>Time</small>
|
211
|
+
|
212
|
+
</li>
|
213
|
+
|
214
|
+
|
215
|
+
<li class="r2 ">
|
216
|
+
<a href="Time.html#prev_minute-instance_method" title="Time#prev_minute (method)">#prev_minute</a>
|
217
|
+
|
218
|
+
<small>Time</small>
|
219
|
+
|
220
|
+
</li>
|
221
|
+
|
222
|
+
|
223
|
+
<li class="r1 ">
|
224
|
+
<a href="Time.html#prev_quarter-instance_method" title="Time#prev_quarter (method)">#prev_quarter</a>
|
225
|
+
|
226
|
+
<small>Time</small>
|
227
|
+
|
228
|
+
</li>
|
229
|
+
|
230
|
+
|
231
|
+
<li class="r2 ">
|
232
|
+
<a href="Time.html#prev_second-instance_method" title="Time#prev_second (method)">#prev_second</a>
|
233
|
+
|
234
|
+
<small>Time</small>
|
235
|
+
|
236
|
+
</li>
|
237
|
+
|
238
|
+
|
239
|
+
<li class="r1 ">
|
240
|
+
<a href="Time.html#prev_week-instance_method" title="Time#prev_week (method)">#prev_week</a>
|
241
|
+
|
242
|
+
<small>Time</small>
|
243
|
+
|
244
|
+
</li>
|
245
|
+
|
246
|
+
|
247
|
+
<li class="r2 ">
|
248
|
+
<a href="Time.html#quarters_ago-instance_method" title="Time#quarters_ago (method)">#quarters_ago</a>
|
249
|
+
|
250
|
+
<small>Time</small>
|
251
|
+
|
252
|
+
</li>
|
253
|
+
|
254
|
+
|
255
|
+
<li class="r1 ">
|
256
|
+
<a href="Time.html#quarters_since-instance_method" title="Time#quarters_since (method)">#quarters_since</a>
|
257
|
+
|
258
|
+
<small>Time</small>
|
259
|
+
|
260
|
+
</li>
|
261
|
+
|
262
|
+
|
263
|
+
<li class="r2 ">
|
264
|
+
<a href="Time.html#round-instance_method" title="Time#round (method)">#round</a>
|
265
|
+
|
266
|
+
<small>Time</small>
|
267
|
+
|
268
|
+
</li>
|
269
|
+
|
270
|
+
|
271
|
+
<li class="r1 ">
|
272
|
+
<a href="Time.html#weeks_ago-instance_method" title="Time#weeks_ago (method)">#weeks_ago</a>
|
273
|
+
|
274
|
+
<small>Time</small>
|
275
|
+
|
276
|
+
</li>
|
277
|
+
|
278
|
+
|
279
|
+
<li class="r2 ">
|
280
|
+
<a href="Time.html#weeks_since-instance_method" title="Time#weeks_since (method)">#weeks_since</a>
|
281
|
+
|
282
|
+
<small>Time</small>
|
283
|
+
|
284
|
+
</li>
|
285
|
+
|
286
|
+
|
287
|
+
</ul>
|
288
|
+
</div>
|
289
|
+
</body>
|
290
|
+
</html>
|
291
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta name="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>Top Level Namespace</title>
|
7
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
8
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
|
10
|
+
<script type="text/javascript" charset="utf-8">
|
11
|
+
relpath = '';
|
12
|
+
if (relpath != '') relpath += '/';
|
13
|
+
</script>
|
14
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body>
|
19
|
+
<script type="text/javascript" charset="utf-8">
|
20
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
21
|
+
</script>
|
22
|
+
|
23
|
+
<div id="header">
|
24
|
+
<div id="menu">
|
25
|
+
|
26
|
+
<a href="_index.html">Index</a> »
|
27
|
+
|
28
|
+
|
29
|
+
<span class="title">Top Level Namespace</span>
|
30
|
+
|
31
|
+
|
32
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="search">
|
36
|
+
<a id="class_list_link" href="#">Class List</a>
|
37
|
+
<a id="method_list_link" href="#">Method List</a>
|
38
|
+
<a id ="file_list_link" href="#">File List</a>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div class="clear"></div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<iframe id="search_frame"></iframe>
|
45
|
+
|
46
|
+
<div id="content"><h1>Top Level Namespace
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
</h1>
|
51
|
+
|
52
|
+
<dl class="box">
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
</dl>
|
62
|
+
<div class="clear"></div>
|
63
|
+
|
64
|
+
<h2>Defined Under Namespace</h2>
|
65
|
+
<p class="children">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<strong class="classes">Classes:</strong> <a href="Time.html" title="Time (class)">Time</a>
|
71
|
+
|
72
|
+
|
73
|
+
</p>
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<div id="footer">
|
82
|
+
Generated on Tue Jul 27 20:16:37 2010 by
|
83
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool">yard</a>
|
84
|
+
0.5.8 (ruby-1.8.7).
|
85
|
+
</div>
|
86
|
+
|
87
|
+
</body>
|
88
|
+
</html>
|
data/lib/time/ext.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'time_ext'
|
@@ -0,0 +1,191 @@
|
|
1
|
+
class Time
|
2
|
+
|
3
|
+
# Helper method for backwards compatibility with ActiveSupport.
|
4
|
+
def days_into_week
|
5
|
+
defined?(DAYS_INTO_WEEK) ? DAYS_INTO_WEEK : { :monday => 0, :tuesday => 1, :wednesday => 2, :thursday => 3, :friday => 4, :saturday => 5, :sunday => 6 }
|
6
|
+
end
|
7
|
+
|
8
|
+
# Helper method for backwards compatibility with ActiveSupport.
|
9
|
+
def common_year_days_in_month
|
10
|
+
defined?(COMMON_YEAR_DAYS_IN_MONTH) ? COMMON_YEAR_DAYS_IN_MONTH : [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns a new Time representing the start of the unit specified (second by default).
|
14
|
+
def floor(unit = :sec)
|
15
|
+
self.send("beginning_of_#{unit}")
|
16
|
+
end
|
17
|
+
alias :beginning_of :floor
|
18
|
+
alias :at_beginning_of :floor
|
19
|
+
|
20
|
+
# Returns a new Time representing the start of the next unit specified (second by default).
|
21
|
+
def ceil(unit = :sec)
|
22
|
+
self.send("next_#{unit}").send("beginning_of_#{unit}")
|
23
|
+
end
|
24
|
+
alias :beginning_of_next :ceil
|
25
|
+
alias :at_beginning_of_next :ceil
|
26
|
+
|
27
|
+
# Returns a new Time representing the start of the current or next unit specified (second by default) depending which is closest
|
28
|
+
def round(unit = :sec)
|
29
|
+
next_unit = self.ceil(unit)
|
30
|
+
this_unit = self.floor(unit)
|
31
|
+
(self - this_unit) < (next_unit - self) ? this_unit : next_unit
|
32
|
+
end
|
33
|
+
alias :beginning_of_closest :round
|
34
|
+
|
35
|
+
# Short-hand for seconds_ago(1).
|
36
|
+
def prev_second
|
37
|
+
ago(1)
|
38
|
+
end
|
39
|
+
alias :prev_sec :prev_second
|
40
|
+
|
41
|
+
# Short-hand for seconds_since(1).
|
42
|
+
def next_second
|
43
|
+
since(1)
|
44
|
+
end
|
45
|
+
alias :next_sec :next_second
|
46
|
+
|
47
|
+
# Short-hand for minutes_ago(1).
|
48
|
+
def prev_minute
|
49
|
+
minutes_ago(1)
|
50
|
+
end
|
51
|
+
alias :prev_min :prev_minute
|
52
|
+
|
53
|
+
# Short-hand for minutes_since(1).
|
54
|
+
def next_minute
|
55
|
+
minutes_since(1)
|
56
|
+
end
|
57
|
+
alias :next_min :next_minute
|
58
|
+
|
59
|
+
# Short-hand for hours_ago(1).
|
60
|
+
def prev_hour
|
61
|
+
hours_ago(1)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Short-hand for hours_since(1).
|
65
|
+
def next_hour
|
66
|
+
hours_since(1)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Short-hand for days_ago(1).
|
70
|
+
def prev_day
|
71
|
+
days_ago(1)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Short-hand for days_since(1).
|
75
|
+
def next_day
|
76
|
+
days_since(1)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns a new Time representing the start of the given day in the previous week (default is Monday).
|
80
|
+
def prev_week(day = :monday)
|
81
|
+
weeks_ago(1).beginning_of_week.since(days_into_week[day].day).change(:hour => 0)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Short-hand for quarters_since(1).beginning_of_quarter.
|
85
|
+
def next_quarter
|
86
|
+
quarters_since(1).beginning_of_quarter
|
87
|
+
end
|
88
|
+
|
89
|
+
# Short-hand for quarters_ago(1).beginning_of_quarter.
|
90
|
+
def prev_quarter
|
91
|
+
quarters_ago(1).beginning_of_quarter
|
92
|
+
end
|
93
|
+
|
94
|
+
# Aliases to keep available method names to a standard pattern.
|
95
|
+
alias :secs_ago :ago
|
96
|
+
alias :seconds_ago :ago
|
97
|
+
alias :secs_since :since
|
98
|
+
alias :seconds_since :since
|
99
|
+
|
100
|
+
# Returns a new Time representing the time a number of specified minutes ago.
|
101
|
+
def minutes_ago(minutes)
|
102
|
+
ago(minutes.minutes)
|
103
|
+
end
|
104
|
+
alias :mins_ago :minutes_ago
|
105
|
+
|
106
|
+
# Returns a new Time representing the time a number of specified minutes in the future.
|
107
|
+
def minutes_since(minutes)
|
108
|
+
since(minutes.minutes)
|
109
|
+
end
|
110
|
+
alias :mins_since :minutes_since
|
111
|
+
|
112
|
+
# Returns a new Time representing the time a number of specified hours ago.
|
113
|
+
def hours_ago(hours)
|
114
|
+
ago(hours.hours)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Returns a new Time representing the time a number of specified hours in the future.
|
118
|
+
def hours_since(hours)
|
119
|
+
since(hours.hours)
|
120
|
+
end
|
121
|
+
|
122
|
+
# Returns a new Time representing the time a number of specified days ago.
|
123
|
+
def days_ago(days)
|
124
|
+
ago(days.days)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Returns a new Time representing the time a number of specified days in the future.
|
128
|
+
def days_since(days)
|
129
|
+
since(days.days)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns a new Time representing the time a number of specified weeks ago.
|
133
|
+
def weeks_ago(weeks)
|
134
|
+
ago(weeks.weeks)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Returns a new Time representing the time a number of specified weeks in the future.
|
138
|
+
def weeks_since(weeks)
|
139
|
+
since(weeks.weeks)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns a new Time representing the time a number of specified quarters (3 months) ago.
|
143
|
+
def quarters_ago(quarters)
|
144
|
+
ago((quarters * 3).months)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Returns a new Time representing the time a number of specified quarters (3 months) in the future.
|
148
|
+
def quarters_since(quarters)
|
149
|
+
since((quarters * 3).months)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns a new Time representing the start of the second, XX:XX:XX.000000 (.000000000 in ruby1.9).
|
153
|
+
def beginning_of_second
|
154
|
+
change(:usec => 0)
|
155
|
+
end
|
156
|
+
alias :beginning_of_sec :beginning_of_second
|
157
|
+
alias :at_beginning_of_sec :beginning_of_second
|
158
|
+
alias :at_beginning_of_second :beginning_of_second
|
159
|
+
|
160
|
+
# Returns a new Time representing the end of the hour, XX:XX:XX.999999 (.999999999 in ruby1.9).
|
161
|
+
def end_of_second
|
162
|
+
change(:usec => 999999.999)
|
163
|
+
end
|
164
|
+
alias :end_of_sec :end_of_second
|
165
|
+
|
166
|
+
# Returns a new Time representing the start of the minute (XX:XX:00).
|
167
|
+
def beginning_of_minute
|
168
|
+
change(:sec => 0, :usec => 0)
|
169
|
+
end
|
170
|
+
alias :beginning_of_min :beginning_of_minute
|
171
|
+
alias :at_beginning_of_min :beginning_of_minute
|
172
|
+
alias :at_beginning_of_minute :beginning_of_minute
|
173
|
+
|
174
|
+
# Returns a new Time representing the end of the hour, XX:XX:59.999999 (.999999999 in ruby1.9).
|
175
|
+
def end_of_minute
|
176
|
+
change(:sec => 59, :usec => 999999.999)
|
177
|
+
end
|
178
|
+
alias :end_of_min :end_of_minute
|
179
|
+
|
180
|
+
# Returns a new Time representing the start of the hour (XX:00:00).
|
181
|
+
def beginning_of_hour
|
182
|
+
change(:min => 0, :sec => 0, :usec => 0)
|
183
|
+
end
|
184
|
+
alias :at_beginning_of_hour :beginning_of_hour
|
185
|
+
|
186
|
+
# Returns a new Time representing the end of the hour, XX:59:59.999999 (.999999999 in ruby1.9).
|
187
|
+
def end_of_hour
|
188
|
+
change(:min => 59, :sec => 59, :usec => 999999.999)
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
data/lib/time_ext.rb
ADDED
data/spec/spec.opts
ADDED