Incorrect calculation in "RemindMeLater" code #80

Open
opened 2025-12-29 18:28:57 +01:00 by adam · 0 comments
Owner

Originally created by @jeromeDefReputation on GitHub (Jun 25, 2019).

// If the user wanted to be reminded later, has enough time passed?
        let timeIntervalOfReminder = userDefaultsObject?.doubleForKey(keyForArmchairKeyType(ArmchairKey.ReminderRequestDate))
        if let timeInterval = timeIntervalOfReminder {
            let reminderRequestDate = Date(timeIntervalSince1970: timeInterval)
            let timeSinceReminderRequest = Date().timeIntervalSince(reminderRequestDate)
            let timeUntilReminder: TimeInterval = 60 * 60 * 24 * Double(daysBeforeReminding)
            if timeSinceReminderRequest < timeUntilReminder {
                return false
            }
        } else {
            return false
        }

If the amount of time since the current timestamp and the request timestamp is greater than 0, return true if by 'true' is we can show prompt.

Originally created by @jeromeDefReputation on GitHub (Jun 25, 2019). ``` // If the user wanted to be reminded later, has enough time passed? let timeIntervalOfReminder = userDefaultsObject?.doubleForKey(keyForArmchairKeyType(ArmchairKey.ReminderRequestDate)) if let timeInterval = timeIntervalOfReminder { let reminderRequestDate = Date(timeIntervalSince1970: timeInterval) let timeSinceReminderRequest = Date().timeIntervalSince(reminderRequestDate) let timeUntilReminder: TimeInterval = 60 * 60 * 24 * Double(daysBeforeReminding) if timeSinceReminderRequest < timeUntilReminder { return false } } else { return false } ``` If the amount of time since the current timestamp and the request timestamp is greater than 0, return true if by 'true' is we can show prompt.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Armchair#80