compact_time 0.6.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/compact_time.rb +17 -28
  3. metadata +9 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44554cbc05d9b4e1d994a17e74e867db36bc45ce
4
- data.tar.gz: a50501657f15b4c67e3081bcdd292af67ed5cf55
3
+ metadata.gz: 7289b3ad9f58839f6e966e1ddaf3ee61ad0ffa23
4
+ data.tar.gz: acf695317788a30fdd17258bd05bae32b29b09ca
5
5
  SHA512:
6
- metadata.gz: 6458be7641028f96bab5c96b29499fe451fd1a051fdf5e604146d333c4a4f1b76b6880d1495413e2077f4024fe08581e5d165a905c431990c049c47bfae43d01
7
- data.tar.gz: 636980d0bfcc431c275e5c6baf3f8e486864f5032f8725d4f7b406ce6f5c9d1fadf2df7d23e9a9042c068fbdc5b8633c5400774afe48d5a3077376418d148f1a
6
+ metadata.gz: d9f2bf7f6170a3dacf2d6db9b743f7cd9cbd284a67ad293d38d5a3370334073e8250f32a762fdd841074d1314562e9ba9d0cc0712cef55292a2df4a20fc3e285
7
+ data.tar.gz: 389a57c008f2c47d8342fe76a332627698889a6e48aa16fc9a0767eb139c2cd80dbd23c6cb484f42ba85f919cf9ae3dd2650833a80ef13e98d6d37461e3a82d2
@@ -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
- def till_now; self.class.now - self end
5
- def compact_array
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
- Alph = %w[dummy A B C D E F G]
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)
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.6.1
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: 2015-12-25 00:00:00.000000000 Z
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.5.1
42
+ rubygems_version: 2.6.4
40
43
  signing_key:
41
44
  specification_version: 4
42
- summary: Compact way of expressing time
45
+ summary: Compact and logical notation for time objects
43
46
  test_files: []