units-time 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76fe6741c76332996673e18c6d299f1fa85dc014
4
- data.tar.gz: b7c77366854058091dd6223196cfdb63950269b9
3
+ metadata.gz: 85825ae67f49319633b3464c0a752a720d9a8a4c
4
+ data.tar.gz: 86166febad3c6aa8cae454ac4ca9e0e5363bf7ce
5
5
  SHA512:
6
- metadata.gz: 074f4a4717ef00dd8023f4daa8dbe1760aa7caaf6dc056bf825cccd2c2c2dde311ca8d5e4761e888da96b8750f6d0c5f37644a2c4fb9ad2992f64c78f25d4ee4
7
- data.tar.gz: df29e7ca34b97c40740e8e6fb450224c46f1a9cf1a6f92d6b4b483a6f15b2c65ebd6852f196e9f67c4ed64223910ac6ac0be69400447c87ead00d3ee24ec2cd8
6
+ metadata.gz: eeb084bd4553ca0f1f0f446e1832c22e3cd5a9893ffd160bee4d6b7eec2d537ee5270f61b2cbdc720bbd3fab702377be18986e69a7237b1d403fa7daf958fc02
7
+ data.tar.gz: d53de4ff638e3e0bbd527d4a8451b2aac67b8d58d60ab851f0ef1e7d0dd2df92012a3a1ce6aeb67e0d44873db249b0ca7a7e2b7b4848d7f25025d26c95694130
@@ -3,7 +3,8 @@
3
3
 
4
4
  class Timestamp
5
5
 
6
- def self.now() new( Time.now.to_i ); end
6
+ ## todo: double check that Time.now.to_i always returns seconds in utc/gmt "universal" time (and not local time)
7
+ def self.now() new; end
7
8
 
8
9
  attr_reader :seconds
9
10
 
@@ -31,6 +32,9 @@ class Timestamp
31
32
  def -( other )
32
33
  if other.is_a?( Timedelta )
33
34
  self.class.new( @seconds - other.seconds )
35
+ elsif other.is_a?( Timestamp ) ## note: returns Timedelta class/object!!!
36
+ ## todo: check how to deal with negative timedelta - allow !? - why? why not?
37
+ Timedelta.new( @seconds - other.seconds )
34
38
  else
35
39
  raise TypeError.new( "[Timestamp] sub(straction) - wrong type >#{other.inspect}< #{other.class.name} - Timedelta expected" )
36
40
  end
@@ -4,7 +4,7 @@ module UnitsTime
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
- PATCH = 1
7
+ PATCH = 2
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -97,6 +97,9 @@ def test_timedelta_ops
97
97
  assert_equal Timedelta, (100 * 1.hour).class
98
98
  assert_equal now+100*3600.secs, now + (100 * 1.hour)
99
99
  assert_equal Timestamp, (now + (100 * 1.hour)).class
100
+
101
+ assert_equal 2.weeks, (now+2.weeks) - now
102
+ assert_equal Timedelta, ((now+2.weeks) - now).class
100
103
  end
101
104
 
102
105
  def test_conv
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: units-time
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer