unichron 0.3.0 → 0.3.5

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
  SHA256:
3
- metadata.gz: 5015cf44e98e7ad21672ebc7e110881dbf92bb8868535c1cda356eb2b7b03737
4
- data.tar.gz: 675b26288b3d0d5e7f92954829035af2afded19ca3914ecb4cfa7ccd786f7b4c
3
+ metadata.gz: c94563f11984c9edc01094f3149c3e79d83458492b5c659f3872ac3e8588ae96
4
+ data.tar.gz: d65aeedccc5da43c22e5585c4d56fdbee6afe22af56b44b24e6b7db5df47a148
5
5
  SHA512:
6
- metadata.gz: '0985dc714f8c376344d5eba7420a6673c54f52fa7e106cf751925f90d0766e9e1f178a9121c7acaee041f3add64d7e0e8ad4104cf52c2d9427adac2189efd3f8'
7
- data.tar.gz: 590cb113bcff92f2a950712639ac949eea5178bde560c27964878c5b99eb6fab06ffcb8e2a3a281bc1f88687cc28b115b4373b059a37cdbae8efd8f1b80b8f70
6
+ metadata.gz: ab7de3b681d9f9e764bca7848add0bf4f2ac1ed3eeb2bc40ebbcace63e134d52a099b75ff434f0aeceffe08b5aec0fcd6a150f3edc934249855c2c4e48b971dc
7
+ data.tar.gz: 6dc77c5dbd27fcadc14f485fa9c3b3bb474e4f87eec1fa678bfaeaaa59532b6b127493d560be39990b1f003e8346f72a371ce336f94cf32f563c40c78923ae4d
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/unichron.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  # file: unichron.rb
4
4
 
5
+ require 'subunit'
5
6
  require 'chronic_cron'
6
7
  require 'christian_calendar'
7
8
 
@@ -10,9 +11,9 @@ class Unichron
10
11
 
11
12
  attr_reader :r
12
13
 
13
- def initialize(obj, debug: false)
14
+ def initialize(obj, mode=nil, debug: false)
14
15
 
15
- @debug = debug
16
+ @mode, @debug = mode, debug
16
17
  @r = select_method(obj)
17
18
 
18
19
  end
@@ -21,14 +22,14 @@ class Unichron
21
22
  # e.g. elapsed(Time.now - 4000) #=> 1h
22
23
  # note: An elapsed time more than a day is returned as a calendar date
23
24
  #
24
- def elapsed()
25
+ def elapsed(limit=:day)
25
26
 
26
27
  elapsed = Time.now - @r
27
28
 
28
29
  relative_time = if elapsed < Time.now - (Date.today - 1).to_time then
29
30
  Subunit.seconds(elapsed).strfunit("%s")
30
31
  else
31
- t2.strftime("%b %d")
32
+ @r.strftime("%b %d")
32
33
  end
33
34
 
34
35
  end
@@ -40,6 +41,10 @@ class Unichron
40
41
  def to_date
41
42
  @r.to_date if valid?
42
43
  end
44
+
45
+ def to_i()
46
+ @r.to_time.to_i if valid?
47
+ end
43
48
 
44
49
  def to_time
45
50
  @r.to_time if valid?
@@ -56,7 +61,13 @@ class Unichron
56
61
  if obj.is_a? String then
57
62
 
58
63
  s = obj
59
- r = Chronic.parse(s)
64
+
65
+ r = if @mode = :little_endian
66
+ Chronic.parse(s, :endian_precedence => :little)
67
+ else
68
+ Chronic.parse(s)
69
+ end
70
+
60
71
  puts 'r1: ' + r.inspect if @debug
61
72
  return r if r
62
73
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unichron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,8 +35,28 @@ cert_chain:
35
35
  vPngqdMCuVEkZm+YuLTXph0I590TF5EmMRQMILYYtjV6ClWHIEa5WlToyO2Fk1OL
36
36
  aagRjWlkRSoGiE7602v0Wo/u
37
37
  -----END CERTIFICATE-----
38
- date: 2021-02-23 00:00:00.000000000 Z
38
+ date: 2021-05-04 00:00:00.000000000 Z
39
39
  dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: subunit
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.8'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.8.3
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.8'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.8.3
40
60
  - !ruby/object:Gem::Dependency
41
61
  name: chronic_cron
42
62
  requirement: !ruby/object:Gem::Requirement
@@ -46,7 +66,7 @@ dependencies:
46
66
  version: '0.6'
47
67
  - - ">="
48
68
  - !ruby/object:Gem::Version
49
- version: 0.6.1
69
+ version: 0.6.2
50
70
  type: :runtime
51
71
  prerelease: false
52
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +76,7 @@ dependencies:
56
76
  version: '0.6'
57
77
  - - ">="
58
78
  - !ruby/object:Gem::Version
59
- version: 0.6.1
79
+ version: 0.6.2
60
80
  - !ruby/object:Gem::Dependency
61
81
  name: christian_calendar
62
82
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file