Skip to content

Conversation

@graycreate
Copy link
Member

Summary

  • Change auto-checkin reset time from midnight (0:00) to 8:00 AM
  • This aligns with V2EX's daily mission reset schedule

Changes

  • SettingState.swift: Add isSameCheckinDay() helper method that calculates "checkin day" based on 8 AM reset time
    • Times before 8 AM belong to previous day's checkin period
    • Times at/after 8 AM belong to current day's checkin period

Test plan

  • Enable auto-checkin in settings
  • Checkin before 8 AM should count as previous day
  • After 8 AM, a new checkin should be allowed
  • Verify checkin works correctly across the 8 AM boundary

🤖 Generated with Claude Code

The auto-checkin now resets at 8:00 AM instead of midnight.
This aligns with V2EX's daily mission reset time.

- Add isSameCheckinDay() helper to calculate "checkin day" based on 8 AM
- Times before 8 AM belong to previous day's checkin period
- Times at/after 8 AM belong to current day's checkin period

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings December 27, 2025 03:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the auto-checkin reset time from midnight (0:00) to 8:00 AM to align with V2EX's daily mission reset schedule. The change introduces a new helper method isSameCheckinDay() that implements custom day-boundary logic where times before 8 AM belong to the previous day's checkin period.

Key changes:

  • Added isSameCheckinDay() method to calculate checkin day boundaries based on 8 AM reset time
  • Updated shouldAutoCheckinToday to use the new 8 AM-based logic instead of midnight-based calendar day comparison

Important consideration: While this PR updates the auto-checkin logic in SettingState.swift, there's an inconsistency in MePage.swift (not part of this PR) where hasCheckedInToday still uses Calendar.current.isDateInToday(), which follows midnight boundaries. This means the UI checkin button may show "已签到" (already checked in) even though auto-checkin would allow another checkin after midnight until 8 AM. This should be addressed in a follow-up change to ensure UI consistency.

let hour = calendar.component(.hour, from: date)
if hour < resetHour {
// Before 8 AM, belongs to previous day's checkin period
let previousDay = calendar.date(byAdding: .day, value: -1, to: date)!
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force unwrapping with ! could potentially crash if calendar.date(byAdding:value:to:) returns nil. While this is unlikely for day arithmetic, it's safer to use optional binding or provide a fallback. Consider using guard-let or nil-coalescing to handle edge cases gracefully.

Suggested change
let previousDay = calendar.date(byAdding: .day, value: -1, to: date)!
guard let previousDay = calendar.date(byAdding: .day, value: -1, to: date) else {
// Fallback to current date components if date calculation fails
return calendar.dateComponents([.year, .month, .day], from: date)
}

Copilot uses AI. Check for mistakes.
Comment on lines +62 to +63
let calendar = Calendar.current
let resetHour = 8 // 8:00 AM
Copy link

Copilot AI Dec 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation uses Calendar.current which respects the user's current timezone. This means the 8 AM reset time is based on the user's local timezone, not V2EX's server timezone (likely China Standard Time, UTC+8). If this is intentional to provide a better user experience, consider adding a comment to clarify this design decision. If the reset should align with V2EX's server time regardless of user location, consider using a fixed timezone instead.

Suggested change
let calendar = Calendar.current
let resetHour = 8 // 8:00 AM
// Use a fixed UTC+8 timezone (Asia/Shanghai) to match V2EX server time,
// so the 8:00 AM reset is consistent regardless of the user's local timezone.
let timeZone = TimeZone(identifier: "Asia/Shanghai")
?? TimeZone(secondsFromGMT: 8 * 60 * 60)
?? Calendar.current.timeZone
var calendar = Calendar(identifier: .gregorian)
calendar.timeZone = timeZone
let resetHour = 8 // 8:00 AM (server time)

Copilot uses AI. Check for mistakes.
@graycreate graycreate merged commit b71749b into main Dec 27, 2025
12 checks passed
@graycreate graycreate deleted the bugfix/checkin-reset-time-8am branch December 27, 2025 03:31
@github-actions
Copy link

Code Coverage Report ❌

Current coverage: 30.65%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants