unichron 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/unichron.rb +23 -5
- metadata +7 -8
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14cf431be524e94cbee2e7c22ac02a5cf3e4e342e7ad4a697d27f5c0d1dc0a9c
|
4
|
+
data.tar.gz: 9eabbe15f5790b9e20506dda62f05791d5074e135a3203a49ef78e66e11b136e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e2a7c859bd570a082d6fc0d6214ec02c3ade19ff8a2f0f0d66da5327acdfdd7f05bc71a62e4f5e4cf979da052e1e8d83d0b913fd093ef9a1b92c5e91e0f2211
|
7
|
+
data.tar.gz: 5a201a79de06d56e554e443ba167d36dcd7577c56d69b35b3df1d367e4ac8ff2691e068cca8ef8dc462e5cb08e8b3c192c18ef04ba2fc4abd31586eeb328b7d6
|
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,7 +22,7 @@ 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
|
|
@@ -40,6 +41,14 @@ class Unichron
|
|
40
41
|
def to_date
|
41
42
|
@r.to_date if valid?
|
42
43
|
end
|
44
|
+
|
45
|
+
def to_datetime
|
46
|
+
@r.to_datetime if valid?
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_i()
|
50
|
+
@r.to_time.to_i if valid?
|
51
|
+
end
|
43
52
|
|
44
53
|
def to_time
|
45
54
|
@r.to_time if valid?
|
@@ -56,7 +65,13 @@ class Unichron
|
|
56
65
|
if obj.is_a? String then
|
57
66
|
|
58
67
|
s = obj
|
59
|
-
|
68
|
+
|
69
|
+
r = if @mode = :little_endian
|
70
|
+
Chronic.parse(s, :endian_precedence => :little)
|
71
|
+
else
|
72
|
+
Chronic.parse(s)
|
73
|
+
end
|
74
|
+
|
60
75
|
puts 'r1: ' + r.inspect if @debug
|
61
76
|
return r if r
|
62
77
|
|
@@ -74,7 +89,10 @@ class Unichron
|
|
74
89
|
|
75
90
|
|
76
91
|
return nil
|
77
|
-
|
92
|
+
|
93
|
+
elsif obj.is_a? Integer
|
94
|
+
r = Time.at obj
|
95
|
+
return r
|
78
96
|
else
|
79
97
|
obj
|
80
98
|
end
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
vPngqdMCuVEkZm+YuLTXph0I590TF5EmMRQMILYYtjV6ClWHIEa5WlToyO2Fk1OL
|
36
36
|
aagRjWlkRSoGiE7602v0Wo/u
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-
|
38
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: subunit
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '0.8'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.8.
|
49
|
+
version: 0.8.5
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version: '0.8'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.8.
|
59
|
+
version: 0.8.5
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: chronic_cron
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0.6'
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.6.
|
69
|
+
version: 0.6.2
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0.6'
|
77
77
|
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: 0.6.
|
79
|
+
version: 0.6.2
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: christian_calendar
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,8 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
|
127
|
-
rubygems_version: 2.7.10
|
126
|
+
rubygems_version: 3.1.2
|
128
127
|
signing_key:
|
129
128
|
specification_version: 4
|
130
129
|
summary: A universal chron tool.
|
metadata.gz.sig
CHANGED
Binary file
|