datet 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,6 @@ GEM
9
9
  rake
10
10
  rdoc
11
11
  json (1.7.3)
12
- json (1.7.3-java)
13
12
  rake (0.9.2.2)
14
13
  rdoc (3.12)
15
14
  json (~> 1.4)
@@ -23,7 +22,6 @@ GEM
23
22
  rspec-mocks (2.8.0)
24
23
 
25
24
  PLATFORMS
26
- java
27
25
  ruby
28
26
 
29
27
  DEPENDENCIES
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.10
1
+ 0.0.11
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{datet}
8
- s.version = "0.0.10"
8
+ s.version = "0.0.11"
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 = %q{2012-07-19}
12
+ s.date = %q{2012-07-20}
13
13
  s.description = %q{A framework for handeling date- and time-related stuff in Ruby.}
14
14
  s.email = %q{k@spernj.org}
15
15
  s.extra_rdoc_files = [
@@ -381,7 +381,7 @@ class Datet
381
381
  self.add_months(1)
382
382
  days_left = (days - 1) - (dim - cur_day)
383
383
  self.add_days(days_left) if days_left != 0
384
- elsif next_day < 0
384
+ elsif next_day <= 0
385
385
  self.add_months(-1)
386
386
  @t_day = self.days_in_month
387
387
  days_left = days + cur_day
@@ -667,7 +667,7 @@ class Datet
667
667
  newhour = newhour.to_f
668
668
 
669
669
  #Add days for every 24 hours given.
670
- if newhour > 24
670
+ if newhour > 24 or newhour < 0
671
671
  days = (newhour.to_f / 24.0).floor
672
672
  newhour -= (days.to_f * 24.0)
673
673
  self.add_days(days)
@@ -701,10 +701,9 @@ class Datet
701
701
  # datet.lazy_min = 90.5 #=> 2012-07-16 20:30:30
702
702
  def lazy_min=(newmin)
703
703
  newmin = newmin.to_f
704
- raise ArgumentError, "Invalid minute: '#{newmin}'." if newmin < 0
705
704
 
706
705
  #Add hours for every 60 minutes given.
707
- if newmin > 60
706
+ if newmin > 60 or newmin < 0
708
707
  hours = (newmin.to_f / 60.0).floor
709
708
  newmin -= (hours.to_f * 60.0)
710
709
  self.add_hours(hours)
@@ -734,9 +733,8 @@ class Datet
734
733
  #Changes the second to a given new second. If more than 60 is given, then the difference is converted into added minutes.
735
734
  def lazy_sec=(newsec)
736
735
  newsec = newsec.to_i
737
- raise ArgumentError, "Invalid second: '#{newsec}'." if newsec < 0
738
736
 
739
- if newsec > 60
737
+ if newsec > 60 or newsec < 0
740
738
  mins = (newsec.to_f / 60.0).floor
741
739
  newsec -= (mins * 60)
742
740
  self.add_mins(mins)
@@ -463,6 +463,10 @@ describe "Datet" do
463
463
  datet = Datet.new(1985, 6, 17, 10)
464
464
  datet.lazy_sec = 125
465
465
  raise "Expected time to be '1985-06-17 10:02:05' but it was: '#{datet.dbstr}'." if datet.dbstr != "1985-06-17 10:02:05"
466
+
467
+ datet = Datet.new(1985, 6, 1, 0, 0, 0)
468
+ datet.lazy_sec = -15
469
+ raise "Expected time to be '1985-05-31 23:59:45' but it was: '#{datet.dbstr}'." if datet.dbstr != "1985-05-31 23:59:45"
466
470
  end
467
471
 
468
472
  it "should be able to set minutes lazy" do
@@ -472,11 +476,19 @@ describe "Datet" do
472
476
 
473
477
  datet.lazy_min = 30.5
474
478
  raise "Expected time to be '1985-06-17 12:30:30' but it was: '#{datet.dbstr}'." if datet.dbstr != "1985-06-17 12:30:30"
479
+
480
+ datet = Datet.new(1985, 6, 1, 0, 0)
481
+ datet.lazy_min = -15
482
+ raise "Expected time to be '1985-05-31 23:45:00' but it was: '#{datet.dbstr}'." if datet.dbstr != "1985-05-31 23:45:00"
475
483
  end
476
484
 
477
485
  it "should be able to set hours lazy" do
478
486
  datet = Datet.new(1985, 6, 17, 10)
479
487
  datet.lazy_hour = 28.5
480
488
  raise "Expected time to be '1985-06-18 04:30:00' but it was: '#{datet.dbstr}'." if datet.dbstr != "1985-06-18 04:30:00"
489
+
490
+ datet = Datet.new(1985, 6, 1, 0)
491
+ datet.lazy_hour = -3
492
+ raise "Expected time to be '1985-05-31 21:00:00' but it was: '#{datet.dbstr}'." if datet.dbstr != "1985-05-31 21:00:00"
481
493
  end
482
494
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: datet
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.10
5
+ version: 0.0.11
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-07-19 00:00:00 +02:00
13
+ date: 2012-07-20 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- hash: -53857754669353741
96
+ hash: 762753016854982512
97
97
  segments:
98
98
  - 0
99
99
  version: "0"