compact_time 0.6.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/compact_time.rb +17 -28
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7289b3ad9f58839f6e966e1ddaf3ee61ad0ffa23
|
4
|
+
data.tar.gz: acf695317788a30fdd17258bd05bae32b29b09ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9f2bf7f6170a3dacf2d6db9b743f7cd9cbd284a67ad293d38d5a3370334073e8250f32a762fdd841074d1314562e9ba9d0cc0712cef55292a2df4a20fc3e285
|
7
|
+
data.tar.gz: 389a57c008f2c47d8342fe76a332627698889a6e48aa16fc9a0767eb139c2cd80dbd23c6cb484f42ba85f919cf9ae3dd2650833a80ef13e98d6d37461e3a82d2
|
data/lib/compact_time.rb
CHANGED
@@ -1,32 +1,21 @@
|
|
1
|
-
#!/ruby
|
2
1
|
#frozen-string-literal: true
|
2
|
+
|
3
|
+
module CompactTime
|
4
|
+
def compact_date_time; "#{compact_date} #{compact_time}" end
|
5
|
+
def compact_date; "%04d%s%02d%s" % compact_date_array end
|
6
|
+
def compact_time; strftime("%T.%L%:z") end
|
7
|
+
def compact_date_array; [ctn_year, ctn_quatery, ctn_week, ctn_day] end
|
8
|
+
Alph = [nil, "A", "B", "C", "D", "E", "F", "G"]
|
9
|
+
protected def ctn_year; strftime("%G").to_i end
|
10
|
+
protected def ctn_quatery; Alph[strftime("%V").to_i.-(1)./(13).+(1)] end
|
11
|
+
protected def ctn_week; strftime("%V").to_i.-(1).%(13).+(1) end
|
12
|
+
protected def ctn_day; Alph[strftime("%u").to_i] end
|
13
|
+
end
|
14
|
+
|
3
15
|
class Time
|
4
|
-
|
5
|
-
|
6
|
-
[cpt_year % 100, cpt_season, cpt_week, cpt_day, hour, min]
|
7
|
-
end
|
8
|
-
def full_array
|
9
|
-
[cpt_year, cpt_season, cpt_week, cpt_day, hour, min, cpt_offset, sec, usec]
|
10
|
-
end
|
11
|
-
def compact
|
12
|
-
"%02d %s%02d %s%02d%02d" % compact_array
|
13
|
-
end
|
14
|
-
def full
|
15
|
-
"%d %s%02d %s%02d%02d%s %02d %06d" % full_array
|
16
|
-
end
|
16
|
+
include CompactTime
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
private def cpt_year; strftime("%G").to_i end
|
21
|
-
private def cpt_season
|
22
|
-
i = strftime("%V").to_i.-(1)./(13).+(1)
|
23
|
-
i -= 1 if widow_week?
|
24
|
-
Alph[i]
|
25
|
-
end
|
26
|
-
private def cpt_week
|
27
|
-
i = strftime("%V").to_i.-(1).%(13).+(1)
|
28
|
-
widow_week? ? i + 1 : i
|
29
|
-
end
|
30
|
-
private def cpt_day; Alph[strftime("%u").to_i] end
|
31
|
-
private def cpt_offset; strftime("%z") end
|
19
|
+
class Date
|
20
|
+
include CompactTime
|
32
21
|
end
|
metadata
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compact_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
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: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: The gem is an implementation of a proposal by its author to describe
|
14
|
+
date and/or time in a compact and logical way. `Time` objects are assigned a few
|
15
|
+
methods related to expressing them in the proposed notation.
|
14
16
|
email: []
|
15
17
|
executables: []
|
16
18
|
extensions: []
|
@@ -18,7 +20,8 @@ extra_rdoc_files: []
|
|
18
20
|
files:
|
19
21
|
- lib/compact_time.rb
|
20
22
|
homepage: http://sawa.github.io/compact_time
|
21
|
-
licenses:
|
23
|
+
licenses:
|
24
|
+
- MIT
|
22
25
|
metadata: {}
|
23
26
|
post_install_message:
|
24
27
|
rdoc_options: []
|
@@ -36,8 +39,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
36
39
|
version: '0'
|
37
40
|
requirements: []
|
38
41
|
rubyforge_project:
|
39
|
-
rubygems_version: 2.
|
42
|
+
rubygems_version: 2.6.4
|
40
43
|
signing_key:
|
41
44
|
specification_version: 4
|
42
|
-
summary: Compact
|
45
|
+
summary: Compact and logical notation for time objects
|
43
46
|
test_files: []
|