Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ransome
sleek
Commits
9b36258d
Unverified
Commit
9b36258d
authored
May 29, 2021
by
ransome
Committed by
GitHub
May 29, 2021
Browse files
Merge pull request #137 from zerodat/recur_period_fix
fix month, year recurrence periods to be more accurate
parents
c254396c
057fc29d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/js/recurrences.mjs
View file @
9b36258d
...
...
@@ -58,6 +58,7 @@ function generateRecurrence(todo) {
function
getRecurrenceDate
(
due
,
recurrence
)
{
let
recSplit
=
splitRecurrence
(
recurrence
);
let
days
=
0
;
let
months
=
0
;
switch
(
recSplit
.
period
)
{
case
"
d
"
:
days
=
1
;
...
...
@@ -66,12 +67,20 @@ function getRecurrenceDate(due, recurrence) {
days
=
7
;
break
;
case
"
m
"
:
day
s
=
30
;
month
s
=
1
;
break
;
case
"
y
"
:
day
s
=
365
;
month
s
=
12
;
break
;
}
if
(
months
>
0
)
{
let
due_month
=
due
.
getMonth
()
+
recSplit
.
mul
*
months
;
let
due_year
=
due
.
getFullYear
()
+
Math
.
floor
(
due_month
/
12
);
due_month
=
due_month
%
12
;
let
monthlen
=
new
Date
(
due_year
,
due_month
+
1
,
0
).
getDate
();
let
due_day
=
Math
.
min
(
due
.
getDate
(),
monthlen
);
return
new
Date
(
due_year
,
due_month
,
due_day
);
}
due
=
due
.
getTime
();
due
+=
1000
*
60
*
60
*
24
*
recSplit
.
mul
*
days
;
return
new
Date
(
due
);
...
...
Write
Preview
Supports
Markdown
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