Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
d5ff3de3
Commit
d5ff3de3
authored
Jun 09, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a Todo class which has knowledge of start and due dates.
parent
a7db2e8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
0 deletions
+80
-0
Config.py
Config.py
+6
-0
Todo.py
Todo.py
+74
-0
No files found.
Config.py
0 → 100644
View file @
d5ff3de3
"""
This module contains some definitions to configure the application.
"""
TAG_START
=
't'
TAG_DUE
=
'due'
Todo.py
0 → 100644
View file @
d5ff3de3
"""
This module provides the Todo class.
"""
import
datetime
import
Config
import
Utils
import
TodoBase
class
Todo
(
TodoBase
.
TodoBase
):
"""
This class adds common functionality with respect to dates to the Todo
base class, mainly by interpreting the start and due dates of task.
"""
def
__init__
(
self
,
p_str
):
TodoBase
.
TodoBase
.
__init__
(
self
,
p_str
)
def
get_date
(
self
,
p_tag
):
""" Given a date tag, return a date object. """
string
=
self
.
tag_value
(
p_tag
)
return
Utils
.
date_string_to_date
(
string
)
def
start_date
(
self
):
""" Returns a date object of the todo's start date. """
return
self
.
get_date
(
Config
.
TAG_START
)
def
due_date
(
self
):
""" Returns a date object of the todo's due date. """
return
self
.
get_date
(
Config
.
TAG_DUE
)
def
is_active
(
self
):
"""
Returns True when the start date is today or in the past and the
task has not yet been completed.
"""
start
=
self
.
start_date
()
return
not
self
.
is_completed
()
and
\
(
not
start
or
start
<=
datetime
.
date
.
today
())
def
is_overdue
(
self
):
"""
Returns True when the due date is in the past and the task has not
yet been completed.
"""
return
not
self
.
is_completed
()
and
self
.
days_till_due
()
<
0
def
days_till_due
(
self
):
"""
Returns the number of days till the due date. Returns a negative number
of days when the due date is in the past.
Returns 0 when the task has no due date.
"""
due
=
self
.
due_date
()
if
due
:
diff
=
due
-
datetime
.
date
.
today
()
return
diff
.
days
return
0
def
length
(
self
):
"""
Returns the length (in days) of the task, by considering the start date
and the due date. Returns 0 when one of these dates are missing.
"""
start
=
self
.
start_date
()
due
=
self
.
due_date
()
if
start
and
due
:
diff
=
due
-
start
return
diff
.
days
else
:
return
0
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment