Spaces:
Runtime error
Runtime error
Update app.py
Browse filesupdated by o1 Open Ai
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
-
from
|
| 4 |
-
from datetime import date
|
| 5 |
|
| 6 |
# Add a sidebar with radio buttons
|
| 7 |
st.sidebar.title("Navigation")
|
|
@@ -18,55 +17,62 @@ option = st.sidebar.radio(
|
|
| 18 |
),
|
| 19 |
)
|
| 20 |
|
| 21 |
-
# Function to add days to a Hijri date
|
| 22 |
def add_hijri_days(hijri_date, days):
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
return new_hijri_date
|
| 27 |
|
| 28 |
-
# Function to add months to a Hijri date
|
| 29 |
def add_hijri_months(hijri_date, months):
|
| 30 |
-
year = hijri_date.year
|
| 31 |
month = hijri_date.month
|
|
|
|
| 32 |
day = hijri_date.day
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
new_year = total_months // 12
|
| 37 |
new_month = total_months % 12 + 1
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
# Day is invalid in the new month, so advance to first day of next month
|
| 43 |
-
total_months += 1 # Advance one more month
|
| 44 |
-
new_year = total_months // 12
|
| 45 |
-
new_month = total_months % 12 + 1
|
| 46 |
-
new_hijri_date = Hijri(new_year, new_month, 1)
|
| 47 |
|
|
|
|
| 48 |
return new_hijri_date
|
| 49 |
|
| 50 |
-
# Function to add years to a Hijri date
|
| 51 |
def add_hijri_years(hijri_date, years):
|
| 52 |
year = hijri_date.year + years
|
| 53 |
month = hijri_date.month
|
| 54 |
day = hijri_date.day
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
# Day is invalid in the new month, advance to first day of next month
|
| 60 |
-
if month == 12:
|
| 61 |
-
month = 1
|
| 62 |
-
year += 1
|
| 63 |
-
else:
|
| 64 |
-
month += 1
|
| 65 |
-
new_hijri_date = Hijri(year, month, 1)
|
| 66 |
|
|
|
|
| 67 |
return new_hijri_date
|
| 68 |
|
| 69 |
-
# Function to calculate three
|
| 70 |
def three_month_deadlines():
|
| 71 |
st.title("Three Month Deadline Converter")
|
| 72 |
start_date = st.date_input("Select a Gregorian start date")
|
|
@@ -258,4 +264,4 @@ elif option == "Add 20 Years to Filing Date":
|
|
| 258 |
elif option == "Add 15 Years to Filing Date":
|
| 259 |
add_years_to_filing_date(15)
|
| 260 |
elif option == "Add 10 Years to Filing Date":
|
| 261 |
-
add_years_to_filing_date(10)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
from hijridate import Hijri, Gregorian
|
|
|
|
| 4 |
|
| 5 |
# Add a sidebar with radio buttons
|
| 6 |
st.sidebar.title("Navigation")
|
|
|
|
| 17 |
),
|
| 18 |
)
|
| 19 |
|
| 20 |
+
# Function to add days to a Hijri date without using Julian or Gregorian dates
|
| 21 |
def add_hijri_days(hijri_date, days):
|
| 22 |
+
day = hijri_date.day
|
| 23 |
+
month = hijri_date.month
|
| 24 |
+
year = hijri_date.year
|
| 25 |
+
|
| 26 |
+
while days > 0:
|
| 27 |
+
days_in_current_month = Hijri(year, month, 1).month_length()
|
| 28 |
+
remaining_days_in_month = days_in_current_month - day + 1
|
| 29 |
+
|
| 30 |
+
if days >= remaining_days_in_month:
|
| 31 |
+
days -= remaining_days_in_month
|
| 32 |
+
day = 1
|
| 33 |
+
if month == 12:
|
| 34 |
+
month = 1
|
| 35 |
+
year += 1
|
| 36 |
+
else:
|
| 37 |
+
month += 1
|
| 38 |
+
else:
|
| 39 |
+
day += days
|
| 40 |
+
days = 0
|
| 41 |
+
|
| 42 |
+
new_hijri_date = Hijri(year, month, day)
|
| 43 |
return new_hijri_date
|
| 44 |
|
| 45 |
+
# Function to add months to a Hijri date without using Gregorian dates
|
| 46 |
def add_hijri_months(hijri_date, months):
|
|
|
|
| 47 |
month = hijri_date.month
|
| 48 |
+
year = hijri_date.year
|
| 49 |
day = hijri_date.day
|
| 50 |
|
| 51 |
+
total_months = (year - 1) * 12 + (month - 1) + months
|
| 52 |
+
new_year = total_months // 12 + 1
|
|
|
|
| 53 |
new_month = total_months % 12 + 1
|
| 54 |
|
| 55 |
+
max_day = Hijri(new_year, new_month, 1).month_length()
|
| 56 |
+
if day > max_day:
|
| 57 |
+
day = max_day
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
new_hijri_date = Hijri(new_year, new_month, day)
|
| 60 |
return new_hijri_date
|
| 61 |
|
| 62 |
+
# Function to add years to a Hijri date without using Gregorian dates
|
| 63 |
def add_hijri_years(hijri_date, years):
|
| 64 |
year = hijri_date.year + years
|
| 65 |
month = hijri_date.month
|
| 66 |
day = hijri_date.day
|
| 67 |
|
| 68 |
+
max_day = Hijri(year, month, 1).month_length()
|
| 69 |
+
if day > max_day:
|
| 70 |
+
day = max_day
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
new_hijri_date = Hijri(year, month, day)
|
| 73 |
return new_hijri_date
|
| 74 |
|
| 75 |
+
# Function to calculate three-month deadlines
|
| 76 |
def three_month_deadlines():
|
| 77 |
st.title("Three Month Deadline Converter")
|
| 78 |
start_date = st.date_input("Select a Gregorian start date")
|
|
|
|
| 264 |
elif option == "Add 15 Years to Filing Date":
|
| 265 |
add_years_to_filing_date(15)
|
| 266 |
elif option == "Add 10 Years to Filing Date":
|
| 267 |
+
add_years_to_filing_date(10)
|