Spaces:
Runtime error
Runtime error
Commit
·
20046b4
1
Parent(s):
76d9844
Trying Streamlit app
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import datetime
|
3 |
+
from math import ceil
|
4 |
+
|
5 |
+
date_str=st.text_area("Enter a date (format: yyyy-mm-dd): ")
|
6 |
+
|
7 |
+
# Convert the input string to a datetime object
|
8 |
+
date = datetime.datetime.strptime(date_str, "%Y-%m-%d")
|
9 |
+
|
10 |
+
# Calculate the dates 500, 1000, 1500, 2000, and 2500 days after the input date
|
11 |
+
dates_after = []
|
12 |
+
cutoff=(today - date.date()).days+2001
|
13 |
+
day_list=list(range(500,2501,500))+list(range(3000,cutoff,1000))
|
14 |
+
for days in day_list:
|
15 |
+
delta = datetime.timedelta(days=days)
|
16 |
+
dates_after.append(date + delta)
|
17 |
+
|
18 |
+
# Calculate the next multiple of 500 days after the current date
|
19 |
+
delta_days = 500*(ceil((today - date.date()).days/500))
|
20 |
+
next_multiple = date + datetime.timedelta(days=delta_days)
|
21 |
+
|
22 |
+
# Print the results
|
23 |
+
print("Input date:", date.strftime("%Y-%m-%d"))
|
24 |
+
print("Next multiple of 500:", delta_days, "days on", next_multiple.strftime("%Y-%m-%d"),"\n")
|
25 |
+
for i, date_after in enumerate(dates_after):
|
26 |
+
print(f"{day_list[i]} days after input date:", date_after.strftime("%Y-%m-%d"))
|