Skip to content

Commit

Permalink
multiple updates : readme and add loading spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
mskian committed Feb 28, 2024
1 parent 6f10d2d commit 0d56dc1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

Search the country name or timezone to get the current date and time.

WIP 🚧

## usage

- require Python 3
- Require Python 3
- Download and run it (it use JSON data as fallback database from external Source)

```sh

Expand All @@ -20,6 +19,37 @@ python3 wt.py

```

- install locally
- it uses the sqlite3 database from locally installed source

```sh

## Clone the Repo
git clone https://github.com/sanwebinfo/timezone.git
cd timezone

## install Modules
python3 -m pip install -r requirements.txt

or

python -m pip install -r requirements.txt

## Run the CLI
python wt.py

or

python3 wt.py

```

## Database

- all the timezone and country was stored in the folder `/database`
- `db`, `JSON`, and `CSV` data files
- Database build using sqlite3 and pytz and pycountry Module

## LICENSE

MIT
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ six==1.14.0
soupsieve==2.4
spinners==0.0.24
systemd-python==234
termcolor==2.2.0
termcolor==2.4.0
toml==0.10.2
tomli==2.0.1
types-requests==2.25.1
Expand All @@ -128,4 +128,5 @@ websocket-client==1.6.3
Werkzeug==2.2.3
wrapt==1.11.2
xkit==0.0.0
yaspin==2.5.0
zipp==3.15.0
12 changes: 10 additions & 2 deletions wt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import importlib.util
import pytz
import requests
import time
from yaspin import yaspin

packages = ['pytz', 'requests']
spinner = yaspin(text="Searching...", color="cyan")

packages = ['pytz', 'requests', 'yaspin']
missing_packages = [package for package in packages if importlib.util.find_spec(package) is None]

if missing_packages:
Expand Down Expand Up @@ -106,7 +110,7 @@ def get_world_time(timezone):

def main():
try:
country_timezones = load_country_timezones_from_db("/database/country.db")
country_timezones = load_country_timezones_from_db("./database/country.db")
print("\n")
while True:
search_input = input("Enter a country or timezone to get the current time (or 'quit' to exit): ").strip()
Expand All @@ -120,6 +124,10 @@ def main():
print("\n")
continue

spinner.start()
time.sleep(3)
spinner.stop()

if '/' in search_input:
timezones = [search_input]
else:
Expand Down

0 comments on commit 0d56dc1

Please sign in to comment.