compact_time 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/compact_time.rb +11 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44554cbc05d9b4e1d994a17e74e867db36bc45ce
|
4
|
+
data.tar.gz: a50501657f15b4c67e3081bcdd292af67ed5cf55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6458be7641028f96bab5c96b29499fe451fd1a051fdf5e604146d333c4a4f1b76b6880d1495413e2077f4024fe08581e5d165a905c431990c049c47bfae43d01
|
7
|
+
data.tar.gz: 636980d0bfcc431c275e5c6baf3f8e486864f5032f8725d4f7b406ce6f5c9d1fadf2df7d23e9a9042c068fbdc5b8633c5400774afe48d5a3077376418d148f1a
|
data/lib/compact_time.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/ruby
|
2
|
-
|
2
|
+
#frozen-string-literal: true
|
3
3
|
class Time
|
4
4
|
def till_now; self.class.now - self end
|
5
5
|
def compact_array
|
@@ -9,25 +9,24 @@ class Time
|
|
9
9
|
[cpt_year, cpt_season, cpt_week, cpt_day, hour, min, cpt_offset, sec, usec]
|
10
10
|
end
|
11
11
|
def compact
|
12
|
-
"%02d %s%02d %s%02d%02d"
|
12
|
+
"%02d %s%02d %s%02d%02d" % compact_array
|
13
13
|
end
|
14
14
|
def full
|
15
|
-
"%d %s%02d %s%02d%02d%s %02d %06d"
|
15
|
+
"%d %s%02d %s%02d%02d%s %02d %06d" % full_array
|
16
16
|
end
|
17
17
|
|
18
|
-
private
|
19
18
|
Alph = %w[dummy A B C D E F G]
|
20
|
-
protected def widow_week?; strftime("%V"
|
21
|
-
def cpt_year; strftime("%G"
|
22
|
-
def cpt_season
|
23
|
-
i = strftime("%V"
|
19
|
+
protected def widow_week?; strftime("%V").to_i == 53 end
|
20
|
+
private def cpt_year; strftime("%G").to_i end
|
21
|
+
private def cpt_season
|
22
|
+
i = strftime("%V").to_i.-(1)./(13).+(1)
|
24
23
|
i -= 1 if widow_week?
|
25
24
|
Alph[i]
|
26
25
|
end
|
27
|
-
def cpt_week
|
28
|
-
i = strftime("%V"
|
26
|
+
private def cpt_week
|
27
|
+
i = strftime("%V").to_i.-(1).%(13).+(1)
|
29
28
|
widow_week? ? i + 1 : i
|
30
29
|
end
|
31
|
-
def cpt_day; Alph[strftime("%u"
|
32
|
-
def cpt_offset; strftime("%z"
|
30
|
+
private def cpt_day; Alph[strftime("%u").to_i] end
|
31
|
+
private def cpt_offset; strftime("%z") end
|
33
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compact_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email: []
|
@@ -36,7 +36,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
36
|
version: '0'
|
37
37
|
requirements: []
|
38
38
|
rubyforge_project:
|
39
|
-
rubygems_version: 2.
|
39
|
+
rubygems_version: 2.5.1
|
40
40
|
signing_key:
|
41
41
|
specification_version: 4
|
42
42
|
summary: Compact way of expressing time
|