Sanket Kathrotiya commited on
Commit
f89e163
·
1 Parent(s): 2332b04
Files changed (2) hide show
  1. app.py +13 -10
  2. requirements.txt +1 -1
app.py CHANGED
@@ -1,18 +1,21 @@
1
  import gradio as gr
2
- from gradio_calendar import Calendar
3
- import datetime
4
 
5
- def is_weekday(date: datetime.datetime):
6
- return "Yes" if date.weekday() < 5 else "No"
 
 
 
7
 
 
8
  demo = gr.Interface(
9
- fn=is_weekday,
10
- inputs=[Calendar(type="datetime", label="Select a date", info="Click the calendar icon to bring up the calendar.")],
11
- outputs=gr.Label(label="Is it a weekday?"),
12
- examples=[["2023-01-01"], ["2023-12-11"]],
13
- cache_examples=True,
14
- title="Is it a weekday?"
15
  )
16
 
 
17
  if __name__ == "__main__":
18
  demo.launch()
 
1
  import gradio as gr
2
+ from datetime import datetime
 
3
 
4
+ def is_weekday(date: datetime):
5
+ # Check if the selected date is a weekday (Monday to Friday)
6
+ if isinstance(date, str):
7
+ date = datetime.fromisoformat(date)
8
+ return "Yes, it's a weekday." if date.weekday() < 5 else "No, it's a weekend."
9
 
10
+ # Create the Gradio interface with the DateTime component
11
  demo = gr.Interface(
12
+ fn=is_weekday, # Function to check if the selected date is a weekday
13
+ inputs=gr.DateTime(label="Select a date and time", type="datetime", include_time=True),
14
+ outputs=gr.Textbox(label="Is it a weekday?"),
15
+ examples=["2024-08-29 14:00:00", "2024-08-30 09:30:00"], # Example dates for users to try
16
+ title="Weekday Checker"
 
17
  )
18
 
19
+ # Launch the Gradio interface
20
  if __name__ == "__main__":
21
  demo.launch()
requirements.txt CHANGED
@@ -2,4 +2,4 @@ numpy==1.26.4
2
  pandas==2.2.2
3
  xgboost==2.1.1
4
  gradio
5
- gradio_calendar
 
2
  pandas==2.2.2
3
  xgboost==2.1.1
4
  gradio
5
+