Skip to content

Commit

Permalink
feat: Add support to configure custom date (closes #141)
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Oct 18, 2023
1 parent df77792 commit 3bbebde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions dooit/ui/widgets/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
TODOS = config_man.get("TODO")
WORKSPACES = config_man.get("WORKSPACE")


RED = config_man.get("red")
YELLOW = config_man.get("yellow")
GREEN = config_man.get("green")
ORANGE = config_man.get("orange")

DATE_FORMAT = config_man.get("DATE_FORMAT")

DATE_MAX_WIDTH = 17


Expand Down Expand Up @@ -102,12 +105,19 @@ def draw(self) -> str:
icon = TODOS["due_icon"]
style = getattr(self.screen, "date_style")

due: datetime = getattr(self.model, f"_{self._property}")._value

if style == "classic":
value = super().draw()
if not value or value == "none":
if not due:
return ""

time = due.time()
if time.hour == time.minute == 0:
return due.strftime(DATE_FORMAT)
else:
return due.strftime(f"{DATE_FORMAT} %H:%M")

else:
due: datetime = getattr(self.model, f"_{self._property}")._value
if not due:
return ""

Expand Down
1 change: 1 addition & 0 deletions dooit/utils/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def get_username():
YANK_COLOR = blue
SAVE_ON_ESCAPE = False
USE_DAY_FIRST = True
DATE_FORMAT = "%d %h"

#################################
# DASHBOARD #
Expand Down

0 comments on commit 3bbebde

Please sign in to comment.