world_time_ruby 0.0.0
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/world_time.rb +24 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 29f434fadae6193c3462a9ccac4dd89cda3e714f99389b0a7db116ac3d1954ee
|
4
|
+
data.tar.gz: 25242584e8e990a2b8398d7ae048a1faa1584679df2c0d47d3126c7613199643
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7c09420df1bca4d48723ab1ba403b7a0c299bd5b12ec77d566dfc0b7613f7708b9226460437f6512256d9bd05c0dd1ed381a472d421719fad8930e42cdf44923
|
7
|
+
data.tar.gz: 293c78a21173e326926f2fd4539c97e35fd5bca9a0947bf3c723bc0c8f57f8b5d544a95abde923614f2b5a606b29f9689db970e865ad0655034b5b7a58460151
|
data/lib/world_time.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require "json"
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
class WorldTime
|
6
|
+
WORLD_TIME_URL = "http://worldtimeapi.org/api/timezone".freeze
|
7
|
+
def self.timezones(search: nil)
|
8
|
+
response = Net::HTTP.get_response(URI(WORLD_TIME_URL))
|
9
|
+
body = JSON.parse(response.body)
|
10
|
+
if search
|
11
|
+
body.filter { |item| item.include?(search) }
|
12
|
+
else
|
13
|
+
body
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_current_time(area)
|
18
|
+
url_with_area = WORLD_TIME_URL + "/#{area}"
|
19
|
+
response = Net::HTTP.get_response(URI(url_with_area))
|
20
|
+
body = JSON.parse(response.body)
|
21
|
+
d = DateTime.parse(body["datetime"])
|
22
|
+
d.strftime('%I:%M:%S %p')
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: world_time_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Indigo Tech Tutorials
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Gives the current time of anywhere in the world
|
14
|
+
email: indigotech@tutorials.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/world_time.rb
|
20
|
+
homepage: https://rubygems.org/gems/world_time_ruby
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.5.6
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Gives the current time of anywhere in the world
|
43
|
+
test_files: []
|