Pmuscat41 commited on
Commit
352d935
·
verified ·
1 Parent(s): 9f88259

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from hijri_converter import Gregorian
3
+
4
+ # Set the title of the app
5
+ st.title("Gregorian to Hijri Date Converter")
6
+
7
+ # Create a date picker for the user to select a Gregorian date
8
+ start_date = st.date_input("Select a Gregorian start date")
9
+
10
+ # Convert the selected Gregorian date to a Hijri date
11
+ if start_date:
12
+ # Convert Gregorian date to Hijri
13
+ gregorian_date = Gregorian(start_date.year, start_date.month, start_date.day)
14
+ hijri_date = gregorian_date.to_hijri()
15
+
16
+ # Display the Hijri date
17
+ st.write(f"Hijri Date: {hijri_date.isoformat()}")
18
+
19
+ # Function to add months to Hijri date and display the result
20
+ def add_months_and_display(hijri_date, months):
21
+ for i in range(1, months + 1):
22
+ future_hijri_date = hijri_date.add(months=i)
23
+ st.write(f"Date after {i} month(s): {future_hijri_date.isoformat()}")
24
+
25
+ # Calculate and display dates after 1, 2, and 3 months
26
+ add_months_and_display(hijri_date, 3)
27
+
28
+ # Convert the Hijri date back to Gregorian and display it for confirmation
29
+ reconverted_gregorian = hijri_date.to_gregorian()
30
+ st.write(f"Reconverted Gregorian Date: {reconverted_gregorian.isoformat()}")