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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25c640f065caff222020ab2478ec7a70d2f869216d7ebb70a74eee4c09150fad
4
- data.tar.gz: b60e4793e0e890618b40c72b0caf66d1d860cb10e56ef98997d9debf12b20dd8
3
+ metadata.gz: ec0ed27dbbf23f0c3c4bdbfde300b9dfe86d1e36e84c326aee2e645ba30d6730
4
+ data.tar.gz: 7cdac18a30acca38a5178abdfd445dab7dbad145c5443814497e4aa2896e97b2
5
5
  SHA512:
6
- metadata.gz: 591c3cd5f1b343e0f0046ecadc986f9a0d1217279e00f4b9d12f09721d01f282f4c6bb55712f2c6c26e746ff0f1956bf870516bfd00d11af6eca2acef2ceeabd
7
- data.tar.gz: d6b229ad202a8f2d369d9a924bea636943a5839832b413535ca15a1aa808dc122956934e943fad75b7250004bc4bdeceff52a40be6491a5c1a1ab36097d3d838
6
+ metadata.gz: ab629b706ebc9fde7dcf14d343093040084c4756c5e1768717094ed3ae789ddaeb112f2f5e7aafde6e94c3f864c01027ba7b330dbe9c584175275e1dc3ae30e7
7
+ data.tar.gz: 6148eb5ba83596f0a71fd2c7551fd1a173ec189b81cbb8404ecd00900b6f1e5bb6dce69cb1530ed20fe416810adb26e202acad6721e6ed3bf35fd68c6962c4c2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LocalTimeGem
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -1,15 +1,23 @@
1
- require_relative "local_time_gem/version"
2
- require 'timezone'
1
+ require 'tzinfo'
3
2
 
4
3
  module LocalTimeGem
5
4
  class Error < StandardError; end
6
5
 
7
- def self.get_info(city)
8
- timezone = Timezone::Zone.new(zone: city)
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: timezone.time(Time.now),
11
- utc_offset: timezone.offset(Time.now),
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
@@ -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 'timezone', '~> 1.0'
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.3
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: timezone
14
+ name: tzinfo
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
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: '1.0'
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: