Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
Class Manager: Use Datetime spinner for setting lab due dates
Browse files Browse the repository at this point in the history
The new spinner component (Thanks Teikn!) is much more intuitive than typing in
the date as a string.
  • Loading branch information
natecraddock committed Jul 27, 2020
1 parent adaa563 commit b85da1b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions zygrader/class_manager.py
Expand Up @@ -111,20 +111,21 @@ def set_due_date(lab):

labs = data.get_labs()

old_date = ""
old_date = None
if "due" in lab.options:
old_date = lab.options["due"].strftime("%m.%d.%Y:%H.%M.%S")
old_date = lab.options["due"]

due_date = window.create_datetime_spinner("Due Date", time=old_date if old_date else None)

due_date = window.create_text_input("Due Date", "Enter due date [MM.DD.YYYY:HH.MM.SS]", text=old_date)
if due_date == Window.CANCEL:
return

# Clearing the due date
if due_date == "" and "due" in lab.options:
del lab.options["due"]
else:
lab.options["due"] = datetime.datetime.strptime(due_date, "%m.%d.%Y:%H.%M.%S") \
.astimezone(tz=None)
# Remove time zone information
lab.options["due"] = due_date.astimezone(tz=None)

data.write_labs(labs)

Expand Down

0 comments on commit b85da1b

Please sign in to comment.