-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimezone.rb
More file actions
33 lines (32 loc) · 985 Bytes
/
timezone.rb
File metadata and controls
33 lines (32 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby
# frozen_string_literal: true
def what_time(where)
case where
when 'paris'
t = Time.now.utc.localtime("+02:00").strftime("%H:%M")
"Il est #{t} à Paris"
when 'papeete'
t = Time.now.utc.localtime("-10:00").strftime("%H:%M")
"Il est #{t} à Papeete"
when 'londres'
t = Time.now.utc.localtime("+01:00").strftime("%H:%M")
"Il est #{t} à Londres"
when 'new-york'
t = Time.now.utc.localtime("-04:00").strftime("%H:%M")
"Il est #{t} à New York"
when 'tokyo'
t = Time.now.utc.localtime("+09:00").strftime("%H:%M")
"Il est #{t} à Tokyo"
when 'san-fransisco'
t = Time.now.utc.localtime("-07:00").strftime("%H:%M")
"Il est #{t} à San Fransisco"
when 'moscou'
t = Time.now.utc.localtime("+03:00").strftime("%H:%M")
"Il est #{t} à Moscou"
when 'berlin'
t = Time.now.utc.localtime("+02:00").strftime("%H:%M")
"Il est #{t} à Berlin"
else
"Mémé ne connait pas cette ville !"
end
end