date_utils 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. data/lib/date_utils.rb +9 -3
  2. metadata +2 -2
data/lib/date_utils.rb CHANGED
@@ -16,6 +16,8 @@
16
16
  # along with this program; if not, write to the Free Software
17
17
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
18
  #
19
+ require 'date'
20
+
19
21
  module DateUtils
20
22
  # represents a timezone
21
23
  #
@@ -58,8 +60,10 @@ module DateUtils
58
60
  attr_reader :month
59
61
 
60
62
  # create a new Week-instance with the given initial Date
63
+ # if 'date' is nil, create an instance with Date.today
61
64
  #
62
- def initialize(date)
65
+ def initialize(date=nil)
66
+ date = Date.today if date.nil?
63
67
  if date.kind_of?(Date)
64
68
  @month = Month.new(date)
65
69
  @date = date
@@ -113,7 +117,8 @@ module DateUtils
113
117
 
114
118
  # create a new Month of given Date
115
119
  #
116
- def initialize(date)
120
+ def initialize(date=nil)
121
+ date = Date.today if date.nil?
117
122
  if date.kind_of?(Date)
118
123
  @date = date
119
124
  @month = date.month
@@ -160,7 +165,8 @@ module DateUtils
160
165
 
161
166
  # create a new Year -instance with given Date
162
167
  #
163
- def initialize(date)
168
+ def initialize(date=nil)
169
+ date = Date.today if date.nil?
164
170
  unless date.kind_of?(Date)
165
171
  raise ArgumentError, "needs Date as input!"
166
172
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: date_utils
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2007-02-28 00:00:00 +01:00
6
+ version: 0.1.2
7
+ date: 2007-03-01 00:00:00 +01:00
8
8
  summary: Some handy utils to deal with Date
9
9
  require_paths:
10
10
  - lib