datet 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,8 +8,8 @@ GEM
8
8
  git (>= 1.2.5)
9
9
  rake
10
10
  rdoc
11
- json (1.7.5)
12
- rake (0.9.2.2)
11
+ json (1.7.6)
12
+ rake (10.0.3)
13
13
  rdoc (3.12)
14
14
  json (~> 1.4)
15
15
  rspec (2.8.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.20
1
+ 0.0.21
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "datet"
8
- s.version = "0.0.20"
8
+ s.version = "0.0.21"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = "2012-09-08"
12
+ s.date = "2013-01-01"
13
13
  s.description = "A framework for handeling date- and time-related stuff in Ruby."
14
14
  s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
@@ -1,3 +1,5 @@
1
+ require "date" if !Kernel.const_defined?(:Date)
2
+
1
3
  #This class handels various time- and date-specific behaviour in a friendly way.
2
4
  #===Examples
3
5
  # datet = Datet.new #=> 2012-05-03 20:35:16 +0200
@@ -409,7 +411,7 @@ class Datet
409
411
  next_month = cur_month + months.to_i
410
412
 
411
413
  #Check if we have to alter the amount of years based on the month-change.
412
- if next_month > 12 or next_month < 0
414
+ if next_month > 12 or next_month <= 0
413
415
  years = (next_month.to_f / 12.0).floor
414
416
 
415
417
  newmonth = next_month - (years * 12)
@@ -421,6 +423,7 @@ class Datet
421
423
  self.month = newmonth
422
424
  self.add_years(years) if years != 0
423
425
  else
426
+ raise "Invalid month: '#{next_month}'." if next_month <= 0 or next_month > 12
424
427
  @t_month = next_month
425
428
  @t_day = 1
426
429
  end
@@ -99,6 +99,10 @@ describe "Datet" do
99
99
  end
100
100
 
101
101
  it "should be able to handle invalid timestamps" do
102
+ datet = Datet.new(2013, 1, 1, 10, 0, 0)
103
+ datet.add_days(-1)
104
+ raise "Expected dbstr to be '2012-12-31 10:00:00' but it wasnt: '#{datet.dbstr}'." if datet.dbstr != "2012-12-31 10:00:00"
105
+
102
106
  datet = Datet.new(2012, 7, 13, 16, 15, 04)
103
107
  raise "Expected dbstr to be '2012-07-13 16:15:04' but it wasnt: '#{datet.dbstr}'." if datet.dbstr != "2012-07-13 16:15:04"
104
108
 
metadata CHANGED
@@ -1,71 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: datet
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.21
4
5
  prerelease:
5
- version: 0.0.20
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Kasper Johansen
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-09-08 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
18
+ requirements:
20
19
  - - ~>
21
- - !ruby/object:Gem::Version
20
+ - !ruby/object:Gem::Version
22
21
  version: 2.8.0
23
22
  type: :development
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.8.0
30
+ - !ruby/object:Gem::Dependency
27
31
  name: rdoc
28
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
29
33
  none: false
30
- requirements:
34
+ requirements:
31
35
  - - ~>
32
- - !ruby/object:Gem::Version
33
- version: "3.12"
36
+ - !ruby/object:Gem::Version
37
+ version: '3.12'
34
38
  type: :development
35
39
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.12'
46
+ - !ruby/object:Gem::Dependency
38
47
  name: bundler
39
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
40
49
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
44
53
  version: 1.0.0
45
54
  type: :development
46
55
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
49
63
  name: jeweler
50
- requirement: &id004 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
51
65
  none: false
52
- requirements:
66
+ requirements:
53
67
  - - ~>
54
- - !ruby/object:Gem::Version
68
+ - !ruby/object:Gem::Version
55
69
  version: 1.8.4
56
70
  type: :development
57
71
  prerelease: false
58
- version_requirements: *id004
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.8.4
59
78
  description: A framework for handeling date- and time-related stuff in Ruby.
60
79
  email: k@spernj.org
61
80
  executables: []
62
-
63
81
  extensions: []
64
-
65
- extra_rdoc_files:
82
+ extra_rdoc_files:
66
83
  - LICENSE.txt
67
84
  - README.rdoc
68
- files:
85
+ files:
69
86
  - .document
70
87
  - .rspec
71
88
  - Gemfile
@@ -79,34 +96,31 @@ files:
79
96
  - spec/datet_spec.rb
80
97
  - spec/spec_helper.rb
81
98
  homepage: http://github.com/kaspernj/datet
82
- licenses:
99
+ licenses:
83
100
  - MIT
84
101
  post_install_message:
85
102
  rdoc_options: []
86
-
87
- require_paths:
103
+ require_paths:
88
104
  - lib
89
- required_ruby_version: !ruby/object:Gem::Requirement
105
+ required_ruby_version: !ruby/object:Gem::Requirement
90
106
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 4232658486024681942
95
- segments:
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
96
112
  - 0
97
- version: "0"
98
- required_rubygems_version: !ruby/object:Gem::Requirement
113
+ hash: -3943183192918576653
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
115
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: "0"
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
104
120
  requirements: []
105
-
106
121
  rubyforge_project:
107
122
  rubygems_version: 1.8.24
108
123
  signing_key:
109
124
  specification_version: 3
110
125
  summary: A framework for handeling date- and time-related stuff in Ruby.
111
126
  test_files: []
112
-