Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c4abdb1

Browse files
Added timer script
1 parent 1917802 commit c4abdb1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎global-timer/global_time.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /