utc_converter_tool 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NTc3MDU4MzJkY2Y2OTNmYzE3YTgzNzAyYzQ0OGUyN2JlYjcwNGZlZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YjZlZjFlZDlmNzhmZWNmZGI3ZjkyZTVlYTliNWU0Y2JiMTNlY2Y0MQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjY1MjBkMGM3Nzg5NmQyM2I3ODAwYWQ2OTQwODg1MjcxMTUxN2Q5NGU3NTUw
|
10
|
+
YmZkNGEwMjlmMjg2OGNlOTQ0YmRmNTc0ZTI5M2Q5ZGJmYWMyODBlY2U2OWZm
|
11
|
+
MTFjYTMxODkzZmM4NmUxYTQyY2RlMjYxMTJhZWM5ZTRlNDI5Nzg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NGNjZjc5MGRkNjBjMmE0OTMyNDY2NDlhM2I4MDQ5MGJjZmQyOGJjZDNiNTQx
|
14
|
+
ZWNlNjVkNTA5YjhiMGI2ODg1MjAxMDFhODE2YWUxNzIwYmJjMjUwNzI3NjIz
|
15
|
+
NGEzYWY5ZDVlNWY1NWZiNmY0OTQ3ZTg4YzJlYzc4MmNlYmFlYjM=
|
data/lib/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
time_converter
|
2
|
+
==============
|
3
|
+
|
4
|
+
Converts 24 hr UTC time into USA Time
|
5
|
+
|
6
|
+
Description:
|
7
|
+
The goal of this app is to take the default UTC time and convert it to your choice of USA time ('PST', 'EST', 'CST' etc....).
|
8
|
+
Currently, you can see that if you create a new senario and/or alter a current scenario in the .features file the app will successfully
|
9
|
+
convert your time (hours:minutes:seconds ex: 12:00:00) to the selected USA format.
|
10
|
+
|
11
|
+
My eventual goal for this gem is to convert UTC time to any time zone in the world but have yet to complete that work. Also, in its
|
12
|
+
current state daylight savings is not fully implemented so the conversion is currently happening in a non-daylight savings time scenario.
|
13
|
+
Obviously this is my next phase to make this app actually useful. This update will involve knowing the daylight savings dates for each given
|
14
|
+
year and converting according to what year is chosen.
|
15
|
+
|
16
|
+
I can see this program eventually being hooked up to a simple front end UI where the user can select a time (current, future or past time),
|
17
|
+
a date and the desired time zone and will return the accurate time conversion upon clicking the 'convert' button available.
|
@@ -0,0 +1,80 @@
|
|
1
|
+
class Time_Converter
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
#list of Time zones and their UTC Offset
|
5
|
+
UTC_HOUR_OFFSET = {'HST'=>-10, 'AKST'=>-9, 'PST'=>-8,'MST'=>-7, 'CST'=>-6, 'EST'=>-5}
|
6
|
+
|
7
|
+
def initialize hours, minutes, seconds
|
8
|
+
@hours = hours
|
9
|
+
@minutes = minutes
|
10
|
+
@seconds = seconds
|
11
|
+
end
|
12
|
+
|
13
|
+
def selected_timezone selected_timezone
|
14
|
+
@selected_timezone = selected_timezone
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
#------Conversion Methods------#
|
19
|
+
def convert
|
20
|
+
convert_hrs
|
21
|
+
convert_min
|
22
|
+
convert_sec
|
23
|
+
converted_time = "#{convert_hrs}:#{convert_min}:#{convert_sec}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def convert_hrs
|
27
|
+
UTC_Converter UTC_HOUR_OFFSET
|
28
|
+
end
|
29
|
+
|
30
|
+
def convert_min
|
31
|
+
@minutes
|
32
|
+
end
|
33
|
+
|
34
|
+
def convert_sec
|
35
|
+
@seconds
|
36
|
+
end
|
37
|
+
#------Conversion Methods------#
|
38
|
+
|
39
|
+
#------Workhorse Converter-----#
|
40
|
+
def UTC_Converter hash
|
41
|
+
hash.each do |k, v|
|
42
|
+
if k == @selected_timezone
|
43
|
+
converted_hrs = (v.to_i + @hours.to_i) + 24
|
44
|
+
if converted_hrs == 25
|
45
|
+
return "0#{(converted_hrs - 24)}"
|
46
|
+
elsif converted_hrs == 10 or converted_hrs < 25
|
47
|
+
return "#{converted_hrs}"
|
48
|
+
elsif converted_hrs < 34
|
49
|
+
return "0#{(converted_hrs - 24)}"
|
50
|
+
elsif converted_hrs > 25
|
51
|
+
return "#{(converted_hrs - 24)}"
|
52
|
+
elsif converted_hrs > 10
|
53
|
+
return "0#{converted_hrs}"
|
54
|
+
elsif converted_hrs == 0
|
55
|
+
return "24"
|
56
|
+
end
|
57
|
+
return converted_hrs
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
#------Workhorse Converter-----#
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
#FUTURE CODE THAT WILL HELP IMPLEMENT DAYLIGHT SAVINGS TIME
|
66
|
+
|
67
|
+
#list of Time Zones and their UTC offset during daylight savings
|
68
|
+
#UTC_DS_HOUR_OFFSET = {'HST'=>-9, 'AKST'=>-8, 'PST'=>-7,'MST'=>-6, 'CST'=>-5, 'EST'=>-4}
|
69
|
+
|
70
|
+
#def daylight_savings_convert_hrs
|
71
|
+
# UTC_Converter UTC_DS_HOUR_OFFSET
|
72
|
+
#end
|
73
|
+
|
74
|
+
|
75
|
+
#def selected_date year, month, day
|
76
|
+
# @year = year
|
77
|
+
# @month = month
|
78
|
+
# @day = day
|
79
|
+
#end
|
80
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Given(/^I have entered (\d+):(\d+):(\d+)$/) do |arg1, arg2, arg3|
|
2
|
+
@converter = Time_Converter.new(arg1, arg2, arg3)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^I have selected "(.*?)"$/) do |selected_timezone|
|
6
|
+
@converter.selected_timezone(selected_timezone).should eq selected_timezone
|
7
|
+
end
|
8
|
+
|
9
|
+
Given(/^I have selected (\d+)\-(\d+)\-(\d+)$/) do |arg1, arg2, arg3|
|
10
|
+
@converter.selected_date.should eq "#{arg1}-#{arg2}-#{arg3}"
|
11
|
+
end
|
12
|
+
|
13
|
+
When(/^I press convert$/) do
|
14
|
+
@result = @converter.convert
|
15
|
+
end
|
16
|
+
|
17
|
+
Then(/^the result returned should be (\d+):(\d+):(\d+)$/) do |arg1, arg2, arg3|
|
18
|
+
@result.should eq "#{arg1}:#{arg2}:#{arg3}"
|
19
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Feature: 24 hour UTC to USA Time Converter
|
2
|
+
In order to easily convert Current UTC time to USA time
|
3
|
+
As a developer
|
4
|
+
I want to convert the UTC time to the desired USA time zone.
|
5
|
+
|
6
|
+
Scenario:
|
7
|
+
Given I have entered 23:00:00
|
8
|
+
And I have selected "CST"
|
9
|
+
When I press convert
|
10
|
+
Then the result returned should be 17:00:00
|
11
|
+
|
12
|
+
Scenario:
|
13
|
+
Given I have entered 05:00:00
|
14
|
+
And I have selected "EST"
|
15
|
+
When I press convert
|
16
|
+
Then the result returned should be 24:00:00
|
17
|
+
|
18
|
+
Scenario:
|
19
|
+
Given I have entered 22:00:00
|
20
|
+
And I have selected "HST"
|
21
|
+
When I press convert
|
22
|
+
Then the result returned should be 12:00:00
|
23
|
+
|
24
|
+
Scenario:
|
25
|
+
Given I have entered 21:00:00
|
26
|
+
And I have selected "AKST"
|
27
|
+
When I press convert
|
28
|
+
Then the result returned should be 12:00:00
|
29
|
+
|
30
|
+
Scenario:
|
31
|
+
Given I have entered 01:00:00
|
32
|
+
And I have selected "PST"
|
33
|
+
When I press convert
|
34
|
+
Then the result returned should be 17:00:00
|
35
|
+
|
36
|
+
Scenario:
|
37
|
+
Given I have entered 24:00:00
|
38
|
+
And I have selected "MST"
|
39
|
+
When I press convert
|
40
|
+
Then the result returned should be 17:00:00
|
41
|
+
|
42
|
+
Scenario:
|
43
|
+
Given I have entered 22:00:00
|
44
|
+
And I have selected "MST"
|
45
|
+
When I press convert
|
46
|
+
Then the result returned should be 15:00:00
|
47
|
+
|
48
|
+
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: utc_converter_tool
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zack Walkingstick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This gem is intended to convert UTC time to other time zones
|
14
|
+
email: zackwalkingstick@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/README.md
|
20
|
+
- lib/cucumber/features/step_definitions/time_converter.rb
|
21
|
+
- lib/cucumber/features/step_definitions/time_converter_steps.rb
|
22
|
+
- lib/cucumber/features/time_converter.feature
|
23
|
+
homepage: http://rubygems.org/gems/UTC_converter_tool
|
24
|
+
licenses:
|
25
|
+
- GPL-3.0
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.2.2
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: UTC time zone converter
|
47
|
+
test_files: []
|