compact_time 0.0.1
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 +7 -0
- data/lib/compact_time.rb +20 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef9424c978b6d67e23e0ca5910310e2d9db29c5d
|
4
|
+
data.tar.gz: 673816757522776805f8085edad801d61b77f21e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 60bc286bc2a6a66c1de6af2ae969fd8aa3f3dc0592bf6087c4f8d5c38c49c926e6dec5cb0384cdae0633460a98b0851bb28a74b5ffdd99a15e7771cb19131c00
|
7
|
+
data.tar.gz: f8717165ce0ce39b366f7771876a3d8d02b101c4f5b9b16b18ee7a293113a736d759757fe1b097c6906b19f1fcefe3edf6d0cc04fc838ea169bd1bdfa3301bb7
|
data/lib/compact_time.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/ruby
|
2
|
+
|
3
|
+
class Time
|
4
|
+
def till_now; self.class.now - self end
|
5
|
+
end
|
6
|
+
|
7
|
+
## Not to pollute `Time` class. Especially, redefining `Time#wday` may cause server error.
|
8
|
+
class CompactTime < Time
|
9
|
+
def compact_array; [iyear % 100, season, sweek, wday, hour, min] end
|
10
|
+
def compact; "%02d%s-%d%s-%02d%02d" % compact_array end
|
11
|
+
def full_array; [iyear, season, sweek, wday, hour, min, sec, usec] end
|
12
|
+
def full; "%02d%s-%d%s-%02d%02d-%02d-%06d" % full_array end
|
13
|
+
|
14
|
+
private
|
15
|
+
Alph = %w[dummy A B C D E F G]
|
16
|
+
def iyear; strftime("%G").to_i end
|
17
|
+
def season; Alph[strftime("%V").to_i.-(1)./(13).+(1)] end
|
18
|
+
def sweek; strftime("%V").to_i.-(1).%(13).+(1) end
|
19
|
+
def wday; Alph[strftime("%u").to_i] end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compact_time
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: ''
|
14
|
+
email: []
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/compact_time.rb
|
20
|
+
homepage: http://sawa.github.io/compact_time/
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.0.6
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Compact way of expressing time
|
43
|
+
test_files: []
|