Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

World clock #92

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/apps/pages/programs/SimplePrograms/worldClock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from datetime import datetime
import pytz
import streamlit as st
import time

def get_city_time(timezone):
tz = pytz.timezone(timezone)
city_time = datetime.now(tz)
return city_time.strftime('%H:%M:%S'), city_time.strftime('%A, %Y-%m-%d')

def display_world_clock():
st.title("World Clock")

cities = {
"New York": "America/New_York",
"London": "Europe/London",
"Tokyo": "Asia/Tokyo",
"Sydney": "Australia/Sydney",
"Delhi": "Asia/Kolkata",
"Paris": "Europe/Paris"
}

selected_city = st.selectbox("Select a city", list(cities.keys()))

if selected_city:
time_placeholder = st.empty()
date_placeholder = st.empty()

while True:
city_time, city_date = get_city_time(cities[selected_city])
time_placeholder.markdown(f"# {city_time}")
date_placeholder.markdown(f"## {city_date}")
time.sleep(1)

if __name__ == "__main__":
display_world_clock()
5 changes: 4 additions & 1 deletion src/apps/pages/programs/simpleProgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

def simplePrograms():
st.title('Simple Programs')
choice = st.selectbox('Select a program to execute', [None, 'Timer', 'Password Generator','Caeser Cipher', 'Calculator'])
choice = st.selectbox('Select a program to execute', [None, 'Timer', 'Password Generator','Caeser Cipher', 'Calculator', 'World Clock'])

st.markdown('---')

Expand All @@ -18,6 +18,9 @@ def simplePrograms():
elif choice == 'Calculator':
from src.apps.pages.programs.SimplePrograms.calculator import calculator
calculator()
elif choice == 'World Clock':
from src.apps.pages.programs.SimplePrograms.worldClock import display_world_clock
display_world_clock()
else:
st.info("Star this project on [GitHub](https://github.com/Avdhesh-Varshney/Jarvis), if you like it!", icon='⭐')

Expand Down