mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-21 06:34:07 +01:00
parent
9147fb887c
commit
9d246f70cd
2 changed files with 18 additions and 7 deletions
|
|
@ -779,8 +779,8 @@ class TodosController < ApplicationController
|
||||||
if todo.from_recurring_todo?
|
if todo.from_recurring_todo?
|
||||||
recurring_todo = todo.recurring_todo
|
recurring_todo = todo.recurring_todo
|
||||||
|
|
||||||
# check if there are active todos belonging to this recurring todo.
|
# check if there are active todos belonging to this recurring todo. only
|
||||||
# only add new one if all active todos are completed
|
# add new one if all active todos are completed
|
||||||
if recurring_todo.todos.active.count == 0
|
if recurring_todo.todos.active.count == 0
|
||||||
|
|
||||||
# check for next todo either from the due date or the show_from date
|
# check for next todo either from the due date or the show_from date
|
||||||
|
|
@ -788,7 +788,7 @@ class TodosController < ApplicationController
|
||||||
|
|
||||||
# if both due and show_from are nil, check for a next todo from now
|
# if both due and show_from are nil, check for a next todo from now
|
||||||
date_to_check = Time.zone.now if date_to_check.nil?
|
date_to_check = Time.zone.now if date_to_check.nil?
|
||||||
|
|
||||||
if recurring_todo.active? && recurring_todo.has_next_todo(date_to_check)
|
if recurring_todo.active? && recurring_todo.has_next_todo(date_to_check)
|
||||||
|
|
||||||
# shift the reference date to yesterday if date_to_check is furher in
|
# shift the reference date to yesterday if date_to_check is furher in
|
||||||
|
|
@ -799,7 +799,7 @@ class TodosController < ApplicationController
|
||||||
# that new todos due for today will be created instead of new todos
|
# that new todos due for today will be created instead of new todos
|
||||||
# for tomorrow.
|
# for tomorrow.
|
||||||
date = date_to_check.at_midnight >= Time.zone.now.at_midnight ? date_to_check : Time.zone.now-1.day
|
date = date_to_check.at_midnight >= Time.zone.now.at_midnight ? date_to_check : Time.zone.now-1.day
|
||||||
|
|
||||||
new_recurring_todo = create_todo_from_recurring_todo(recurring_todo, date)
|
new_recurring_todo = create_todo_from_recurring_todo(recurring_todo, date)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -471,12 +471,23 @@ class RecurringTodo < ActiveRecord::Base
|
||||||
start = determine_start(previous)
|
start = determine_start(previous)
|
||||||
day = self.every_other1
|
day = self.every_other1
|
||||||
n = self.every_other2
|
n = self.every_other2
|
||||||
|
|
||||||
case self.recurrence_selector
|
case self.recurrence_selector
|
||||||
when 0 # specific day of the month
|
when 0 # specific day of the month
|
||||||
if start.mday >= day
|
if start.mday >= day
|
||||||
# there is no next day n in this month, search in next month
|
# there is no next day n in this month, search in next month
|
||||||
start += n.months
|
#
|
||||||
|
# start += n.months
|
||||||
|
#
|
||||||
|
# The above seems to not work. Fiddle with timezone. Looks like we hit a
|
||||||
|
# bug in rails here where 2008-12-01 +0100 plus 1.month becomes
|
||||||
|
# 2008-12-31 +0100. For now, just calculate in UTC and convert back to
|
||||||
|
# local timezone.
|
||||||
|
#
|
||||||
|
# TODO: recheck if future rails versions have this problem too
|
||||||
|
start = Time.utc(start.year, start.month, start.day)+n.months
|
||||||
|
start = Time.zone.local(start.year, start.month, start.day)
|
||||||
|
|
||||||
# go back to day
|
# go back to day
|
||||||
end
|
end
|
||||||
return Time.zone.local(start.year, start.month, day)
|
return Time.zone.local(start.year, start.month, day)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue