mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-19 16:50:12 +01:00
do not compare at_midnight in different timezones.
Use localtime to make sure both dates are in the same timezone
This commit is contained in:
parent
1dc21daef2
commit
d08ffb3806
3 changed files with 11 additions and 11 deletions
|
|
@ -1051,7 +1051,7 @@ end
|
||||||
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
|
||||||
date_to_check = todo.due.nil? ? todo.show_from : todo.due
|
date_to_check = todo.due.nil? ? todo.show_from.localtime : todo.due.localtime
|
||||||
|
|
||||||
# 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?
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ module RecurringTodos
|
||||||
# TODO: recheck if future rails versions have this problem too
|
# TODO: recheck if future rails versions have this problem too
|
||||||
start = Time.utc(start.year, start.month, start.day)+n.months
|
start = Time.utc(start.year, start.month, start.day)+n.months
|
||||||
end
|
end
|
||||||
Time.zone.local(start.year, start.month, every_x_day)
|
Time.zone.local(start.year, start.month, every_x_day).localtime.at_midnight
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_relative_day_of_month(start, n)
|
def find_relative_day_of_month(start, n)
|
||||||
|
|
|
||||||
|
|
@ -740,14 +740,14 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
# locate the new todo in tickler
|
# locate the new todo in tickler
|
||||||
new_todo = Todo.where(:recurring_todo_id => recurring_todo_1.id, :state => 'deferred').first
|
new_todo = Todo.where(:recurring_todo_id => recurring_todo_1.id, :state => 'deferred').first
|
||||||
assert !new_todo.nil?, "the todo should be in the tickler"
|
refute new_todo.nil?, "the todo should be in the tickler"
|
||||||
|
|
||||||
assert_equal "Call Bill Gates every day", new_todo.description
|
assert_equal "Call Bill Gates every day", new_todo.description
|
||||||
assert_not_equal todo_1.id, new_todo.id, "check that the new todo is not the same as todo_1"
|
assert_not_equal todo_1.id, new_todo.id, "check that the new todo is not the same as todo_1"
|
||||||
assert !new_todo.show_from.nil?, "check that the new_todo is in the tickler to show next month"
|
refute new_todo.show_from.nil?, "check that the new_todo is in the tickler to show next month"
|
||||||
|
|
||||||
# do not use today here. It somehow gets messed up with the timezone calculation.
|
# do not use today here. It somehow gets messed up with the timezone calculation.
|
||||||
next_month = (Time.zone.now + 1.month).at_midnight
|
next_month = (today + 1.month).localtime.at_midnight
|
||||||
|
|
||||||
assert_equal next_month.utc.to_date.to_s(:db), new_todo.show_from.utc.to_date.to_s(:db)
|
assert_equal next_month.utc.to_date.to_s(:db), new_todo.show_from.utc.to_date.to_s(:db)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue