-
Notifications
You must be signed in to change notification settings - Fork 47
fix: change checkin reset time from midnight to 8 AM #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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]>
There was a problem hiding this 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
shouldAutoCheckinTodayto 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)! |
Copilot
AI
Dec 27, 2025
There was a problem hiding this comment.
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.
| 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) | |
| } |
| let calendar = Calendar.current | ||
| let resetHour = 8 // 8:00 AM |
Copilot
AI
Dec 27, 2025
There was a problem hiding this comment.
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.
| 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) |
Code Coverage Report ❌Current coverage: 30.65% |
Summary
Changes
isSameCheckinDay()helper method that calculates "checkin day" based on 8 AM reset timeTest plan
🤖 Generated with Claude Code