mbosse99 commited on
Commit
e8dca67
·
verified ·
1 Parent(s): 8e2d895

upadate with time zones added

Browse files
Files changed (1) hide show
  1. app.py +35 -3
app.py CHANGED
@@ -28,6 +28,33 @@ def get_summary(input_params) -> dict:
28
  print(f"Fehler beim erstellen des Termins: {str(e)}")
29
  st.error(f"Something went wrong: {str(e)}", icon="🚨")
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  if "appointment_response" not in st.session_state:
32
  st.session_state["appointment_response"] = None
33
  if "subject_input" not in st.session_state:
@@ -44,6 +71,7 @@ selected_date = st.date_input("Date of the appointment",format="DD/MM/YYYY")
44
  now = datetime.now()
45
  rounded_now = now + timedelta(minutes=30 - now.minute % 30)
46
  selected_time = st.time_input("Starting time of the appointment", value=rounded_now)
 
47
  selected_duration = st.select_slider("Duration of the appointment in minutes",[15,30,45,60],value=30)
48
  subject_input = st.text_input("Enter the subject of the meeting")
49
  recruiter_mail = st.text_input("Please enter the mail of the recruiter", key="recruiter_mail")
@@ -54,10 +82,13 @@ if not st.session_state["appointment_response"]:
54
  if st.button("Create appointment") or st.session_state["appointment_response"]:
55
  print("nach button appointment")
56
  if subject_input:
57
- start_date_str = datetime.strptime(str(selected_date)+" "+str(selected_time),"%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%dT%H:%M:%S.%fZ")
 
 
58
  print(start_date_str)
59
  end_date = datetime.strptime(str(selected_date)+" "+str(selected_time),"%Y-%m-%d %H:%M:%S") + timedelta(minutes=selected_duration)
60
- end_date_str = end_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
 
61
  with st.spinner("Creating the appointment..."):
62
  request_params = json.dumps({
63
  "appointment": {
@@ -78,7 +109,8 @@ if not st.session_state["appointment_response"]:
78
  "name": st.session_state["candidate_mail"]
79
  }
80
  })
81
- # appointment_response = create_meeting(request_params)
 
82
  # st.write(appointment_response)
83
  if appointment_response:
84
 
 
28
  print(f"Fehler beim erstellen des Termins: {str(e)}")
29
  st.error(f"Something went wrong: {str(e)}", icon="🚨")
30
 
31
+ def adjust_datetime(original_datetime_str, offset_option):
32
+ # Konvertiere den originalen DateTime-String in ein datetime-Objekt
33
+ original_datetime = datetime.strptime(original_datetime_str, "%Y-%m-%dT%H:%M:%S.%fZ")
34
+
35
+ # Überprüfe das Vorzeichen im Offset-String
36
+ if offset_option.startswith('+'):
37
+ # Wenn das Vorzeichen ein Pluszeichen ist, negiere den Offset
38
+ offset_option = '-' + offset_option[1:]
39
+ elif offset_option.startswith('-'):
40
+ offset_option = '+' + offset_option[1:]
41
+ else:
42
+ # Wenn kein Vorzeichen vorhanden ist, füge ein Minuszeichen hinzu
43
+ offset_option = '' + offset_option
44
+
45
+ # Konvertiere die Offset-Option von String zu integer
46
+ offset_hours = int(offset_option)
47
+
48
+ # Erzeuge ein timedelta-Objekt mit dem entsprechenden Offset
49
+ offset_delta = timedelta(hours=offset_hours)
50
+
51
+ # Passe das ursprüngliche datetime-Objekt an
52
+ adjusted_datetime = original_datetime + offset_delta
53
+
54
+ # Formatieren und zurückgeben
55
+ adjusted_datetime_str = adjusted_datetime.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
56
+ return adjusted_datetime_str
57
+
58
  if "appointment_response" not in st.session_state:
59
  st.session_state["appointment_response"] = None
60
  if "subject_input" not in st.session_state:
 
71
  now = datetime.now()
72
  rounded_now = now + timedelta(minutes=30 - now.minute % 30)
73
  selected_time = st.time_input("Starting time of the appointment", value=rounded_now)
74
+ time_zone = st.selectbox("Please select your time zone (based on UTC time)",options=["+10","+9","+8","+7","+6","+5","+4","+3","+2","+1","0","-1","-2","-3","-4","-5","-6","-7","-8","-9","-10"],index=10, key="time_option")
75
  selected_duration = st.select_slider("Duration of the appointment in minutes",[15,30,45,60],value=30)
76
  subject_input = st.text_input("Enter the subject of the meeting")
77
  recruiter_mail = st.text_input("Please enter the mail of the recruiter", key="recruiter_mail")
 
82
  if st.button("Create appointment") or st.session_state["appointment_response"]:
83
  print("nach button appointment")
84
  if subject_input:
85
+ start_date_utc_str = datetime.strptime(str(selected_date)+" "+str(selected_time),"%Y-%m-%d %H:%M:%S").strftime("%Y-%m-%dT%H:%M:%S.%fZ")
86
+ print(start_date_utc_str)
87
+ start_date_str = adjust_datetime(start_date_utc_str, st.session_state["time_option"])
88
  print(start_date_str)
89
  end_date = datetime.strptime(str(selected_date)+" "+str(selected_time),"%Y-%m-%d %H:%M:%S") + timedelta(minutes=selected_duration)
90
+ end_date_utc_str = end_date.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
91
+ end_date_str = adjust_datetime(end_date_utc_str, st.session_state["time_option"])
92
  with st.spinner("Creating the appointment..."):
93
  request_params = json.dumps({
94
  "appointment": {
 
109
  "name": st.session_state["candidate_mail"]
110
  }
111
  })
112
+ appointment_response = create_meeting(request_params)
113
+ # appointment_response = False
114
  # st.write(appointment_response)
115
  if appointment_response:
116