Skip to content

Commit

Permalink
Fix datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
pjreiniger committed Oct 29, 2024
1 parent bc22786 commit 383ce36
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rfidLoginSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,14 @@ def log_attendance(service_key, name, id_num):
last_cell = cell_list[-1]
last_row_num = last_cell.row
last_row = sheet_tab.row_values(last_row_num)
last_logged_date = dt.datetime.strptime(last_row[0], "%m/%d/%y %H:%M %p")
last_logged_date = dt.datetime.strptime(last_row[0], "%m/%d/%y %I:%M %p")
today = dt.date.today()

if today == last_logged_date.date():
if len(last_row) == 4:
# They logged in today so log them out
sheet_tab.update_cell(
last_row_num, 5, current_time.strftime("%m/%d/%y %H:%M %p")
last_row_num, 5, current_time.strftime("%m/%d/%y %I:%M %p")
)
time_diff = current_time - last_logged_date
hours_logged = int(time_diff.seconds / 3600)
Expand All @@ -603,7 +603,7 @@ def log_attendance(service_key, name, id_num):
# They haven't logged in today, so log them in OR...
# User never logged in. Just add it.
sheet_tab.append_row(
[current_time.strftime("%m/%d/%y %H:%M %p"), id_num, name, "General Meeting"]
[current_time.strftime("%m/%d/%y %I:%M %p"), id_num, name, "General Meeting"]
)
return f"{name} is logged in."

Expand All @@ -613,7 +613,7 @@ def log_visitor(service_key, name, team):
current_time = dt.datetime.now()
sheet_tab = google_sheet.worksheet("SCRA Visitor Attendance")
sheet_tab.append_row(
[current_time.strftime("%m/%d/%y %H:%M %p"), team, name, "SCRA Open Meeting"]
[current_time.strftime("%m/%d/%y %I:%M %p"), team, name, "SCRA Open Meeting"]
)


Expand Down

0 comments on commit 383ce36

Please sign in to comment.