local_time_gem 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/local_time_gem/version.rb +1 -1
- data/lib/local_time_gem.rb +15 -7
- data/local_time_gem.gemspec +1 -2
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec0ed27dbbf23f0c3c4bdbfde300b9dfe86d1e36e84c326aee2e645ba30d6730
|
4
|
+
data.tar.gz: 7cdac18a30acca38a5178abdfd445dab7dbad145c5443814497e4aa2896e97b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab629b706ebc9fde7dcf14d343093040084c4756c5e1768717094ed3ae789ddaeb112f2f5e7aafde6e94c3f864c01027ba7b330dbe9c584175275e1dc3ae30e7
|
7
|
+
data.tar.gz: 6148eb5ba83596f0a71fd2c7551fd1a173ec189b81cbb8404ecd00900b6f1e5bb6dce69cb1530ed20fe416810adb26e202acad6721e6ed3bf35fd68c6962c4c2
|
data/lib/local_time_gem.rb
CHANGED
@@ -1,15 +1,23 @@
|
|
1
|
-
|
2
|
-
require 'timezone'
|
1
|
+
require 'tzinfo'
|
3
2
|
|
4
3
|
module LocalTimeGem
|
5
4
|
class Error < StandardError; end
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
# Get local time and UTC difference for a city
|
7
|
+
def self.get_time(city_name)
|
8
|
+
timezone = TZInfo::Timezone.get(city_name)
|
9
|
+
now = Time.now.utc
|
10
|
+
|
11
|
+
# Get local time in the specified timezone
|
12
|
+
local_time = now.in_time_zone(timezone)
|
13
|
+
|
14
|
+
# Calculate UTC difference (hours)
|
15
|
+
utc_offset = local_time.utc_offset / 3600
|
16
|
+
|
17
|
+
# Return formatted information
|
9
18
|
{
|
10
|
-
local_time:
|
11
|
-
|
12
|
-
utc_time: Time.now.utc
|
19
|
+
local_time: local_time.strftime("%H:%M:%S %Z"),
|
20
|
+
utc_difference: utc_offset
|
13
21
|
}
|
14
22
|
end
|
15
23
|
end
|
data/local_time_gem.gemspec
CHANGED
@@ -36,6 +36,5 @@ Gem::Specification.new do |spec|
|
|
36
36
|
|
37
37
|
# For more information and examples about making a new gem, check out our
|
38
38
|
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
-
spec.add_dependency '
|
40
|
-
spec.add_development_dependency 'minitest', '~> 5.0'
|
39
|
+
spec.add_dependency 'tzinfo', '~> 2.0'
|
41
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: local_time_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soumyo78
|
@@ -11,33 +11,19 @@ cert_chain: []
|
|
11
11
|
date: 2024-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: tzinfo
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: minitest
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '5.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '5.0'
|
26
|
+
version: '2.0'
|
41
27
|
description: This Ruby gem allows you to retrieve the current local time and UTC offset
|
42
28
|
for a given city name using the 'timezone' gem.
|
43
29
|
email:
|