date_utils 0.2 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/date_utils.rb +27 -1
- metadata +3 -3
data/lib/date_utils.rb
CHANGED
@@ -157,6 +157,15 @@ module DateUtils
|
|
157
157
|
end
|
158
158
|
|
159
159
|
end
|
160
|
+
|
161
|
+
class Day
|
162
|
+
attr_reader :date
|
163
|
+
|
164
|
+
def initialize(date=nil)
|
165
|
+
@date = date || Date.today
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
160
169
|
|
161
170
|
# Represents a 'Month'
|
162
171
|
#
|
@@ -258,6 +267,12 @@ module DateUtils
|
|
258
267
|
# the Year as an Integer of self
|
259
268
|
attr_reader :year
|
260
269
|
|
270
|
+
# first day of this year
|
271
|
+
attr_reader :first_day
|
272
|
+
|
273
|
+
# last day of this year
|
274
|
+
attr_reader :last_day
|
275
|
+
|
261
276
|
# create a new Year -instance with given Date
|
262
277
|
#
|
263
278
|
def initialize(date=nil)
|
@@ -267,12 +282,14 @@ module DateUtils
|
|
267
282
|
end
|
268
283
|
@year = date.year
|
269
284
|
@date = date
|
285
|
+
@first_day = Date::parse("#{@year}-01-01")
|
286
|
+
@last_day = Date::parse("#{@year}-12-31")
|
270
287
|
end
|
271
288
|
|
272
289
|
# create a Year-instance
|
273
290
|
# call with hash: year
|
274
291
|
# :call-seq:
|
275
|
-
# Year.create(:
|
292
|
+
# Year.create(:year => x)
|
276
293
|
#
|
277
294
|
def self.create(*args)
|
278
295
|
options = Common::extract_options_from_args!(args)
|
@@ -317,5 +334,14 @@ module DateUtils
|
|
317
334
|
! num.kind_of?(Fixnum) || num > 12 ? ArgumentError.new("invalid week-number 'num'"): self.months[num-1]
|
318
335
|
end
|
319
336
|
|
337
|
+
# returns new Year instance one year later
|
338
|
+
# TODO implement
|
339
|
+
def next
|
340
|
+
end
|
341
|
+
|
342
|
+
# returns new Year instance one year previous
|
343
|
+
# TODO implement
|
344
|
+
def previous
|
345
|
+
end
|
320
346
|
end
|
321
347
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: date_utils
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.1
|
7
|
+
date: 2007-06-10 00:00:00 +02:00
|
8
8
|
summary: Some handy utils to deal with Date
|
9
9
|
require_paths:
|
10
10
|
- lib
|