ct 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ct +27 -13
  3. data/lib/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dacf8596cf9425869358fe8bf12d7b77d4b83542
4
- data.tar.gz: 701da3a3340bd0776e7b43753f5b2c298649cdfa
3
+ metadata.gz: 36a02a10a59167cba53cfeb66445092baedd4d9d
4
+ data.tar.gz: b94a70ef2faa59b465447699dac66bd72a593913
5
5
  SHA512:
6
- metadata.gz: ca75f160576ef3f0bf04167b2a9b38346297a449b369fb087046f006fb3b07b18cb10beabddd585cd4be716f93b73cf33cee67b14080271509460f3e39d9ed48
7
- data.tar.gz: 90ede1ad08b3c4b346c0f8c6fb4d3af43f75754bf3c1312aad836a789dd5f6c62f42142657c4a5ccd6f248d77d383112afa71cab640443536c84f816f5055cb2
6
+ metadata.gz: b9cf6afcaf128a5edc81cbe524607e6763865b6186c2fdb3fb15e7e2d55ac68034f09ab7caca075200b2e376b280ccdab9ab23e1fef9944971a4d93d27594751
7
+ data.tar.gz: 8a10cfc94cf6252b8eb56784e7acee1fbf3bcaa98d5fcfd877c746638aadc3a796fe988dddd54124963139a51c07813fa988f4a0f65cb53b0465d7bdedcb45db
data/bin/ct CHANGED
@@ -10,22 +10,36 @@ def formatWithZone(zone)
10
10
  return "%Y-%m-%d %H:%M:%S #{zone.gsub(':','')}"
11
11
  end
12
12
 
13
+ params = {}
14
+
13
15
  opt = OptionParser.new
14
16
  opt.version = CT::VERSION
17
+ opt.on('-u', '--utc hour') {|v| params[:utc] = v}
18
+ opt.parse!(ARGV)
19
+ argv = ARGV
15
20
 
16
- argv = opt.parse!(ARGV)
17
-
18
- a = argv[0]
19
-
20
- if a.nil?
21
+ if params.empty? and argv.length == 0
21
22
  puts Time.now
22
23
  else
23
- localHour = a.downcase
24
- now = DateTime.now
25
- time = DateTime.new(now.year, now.month, now.day, localHour.to_i, now.min, now.sec)
26
- strTime = time.strftime(formatWithZone(now.zone))
27
- localTime = DateTime.parse(strTime)
28
- utcTime = localTime.new_offset(Rational(0, 24))
29
- puts localTime.strftime(formatWithZone(localTime.zone))
30
- puts utcTime.strftime(formatWithZone(utcTime.zone))
24
+ if params.empty? == false
25
+ if params[:utc].empty? == false
26
+ utc = params[:utc]
27
+ utcHour = utc
28
+ now = DateTime.now
29
+ utcTime = DateTime.new(now.year, now.month, now.day, utcHour.to_i, now.min, now.sec)
30
+ localTime = utcTime.new_offset(Rational(now.zone.gsub(':00',''), 24))
31
+ puts utcTime.strftime(formatWithZone(utcTime.zone))
32
+ puts localTime.strftime(formatWithZone(localTime.zone))
33
+ end
34
+ end
35
+ if argv.length > 0
36
+ localHour = argv[0].downcase
37
+ now = DateTime.now
38
+ time = DateTime.new(now.year, now.month, now.day, localHour.to_i, now.min, now.sec)
39
+ strTime = time.strftime(formatWithZone(now.zone))
40
+ localTime = DateTime.parse(strTime)
41
+ utcTime = localTime.new_offset(Rational(0, 24))
42
+ puts localTime.strftime(formatWithZone(localTime.zone))
43
+ puts utcTime.strftime(formatWithZone(utcTime.zone))
44
+ end
31
45
  end
@@ -1,3 +1,3 @@
1
1
  module CT
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dongri Jin