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
df53f811
Commit
df53f811
authored
Jan 10, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs and making pylint happy.
Also add reference to where the code came from.
parent
dd7443f6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
topydo/lib/RelativeDate.py
topydo/lib/RelativeDate.py
+13
-5
No files found.
topydo/lib/RelativeDate.py
View file @
df53f811
...
...
@@ -20,12 +20,20 @@ from datetime import date, timedelta
import
calendar
import
re
def
_add_months
(
sourcedate
,
months
):
month
=
sourcedate
.
month
-
1
+
months
year
=
sourcedate
.
year
+
month
/
12
def
_add_months
(
p_sourcedate
,
p_months
):
"""
Adds a number of months to the source date.
Takes into account shorter months and leap years and such.
https://stackoverflow.com/questions/4130922/how-to-increment-datetime-month-in-python
"""
month
=
p_sourcedate
.
month
-
1
+
p_months
year
=
p_sourcedate
.
year
+
month
/
12
month
=
month
%
12
+
1
day
=
min
(
sourcedate
.
day
,
calendar
.
monthrange
(
year
,
month
)[
1
])
return
date
(
year
,
month
,
day
)
day
=
min
(
p_sourcedate
.
day
,
calendar
.
monthrange
(
year
,
month
)[
1
])
return
date
(
year
,
month
,
day
)
def
_convert_pattern
(
p_length
,
p_periodunit
,
p_offset
=
date
.
today
()):
"""
...
...
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