We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1917802 commit c4abdb1Copy full SHA for c4abdb1
global-timer/global_time.py
@@ -0,0 +1,18 @@
1
+import pytz
2
+import datetime
3
+import argparse
4
+from timezonefinder import TimezoneFinder
5
+from pygeocoder import Geocoder
6
+
7
+location = str(input("Enter location:"))
8
9
+if location != "":
10
+ # Obtain longitude, latitude via Geocoder
11
+ result = Geocoder.geocode(location)
12
+ coordinate = result[0].coordinates
13
+ location = ", ".join([result[0].city, result[0].country])
14
+ # Fetch Timezone by longitude, latitude via timezonefinder
15
+ tf = TimezoneFinder()
16
+ timezone = tf.timezone_at(lat=coordinate[0], lng=coordinate[1])
17
+ time = datetime.datetime.now(pytz.timezone(timezone))
18
+ print("%s %s" % (location, str(time).split('.')[0]))
0 commit comments