Skip to content

Comments

feat: preserve start and end dates during sync (fixes #53)#54

Merged
bigspawn merged 7 commits intomainfrom
feat/preserve-dates
Feb 17, 2026
Merged

feat: preserve start and end dates during sync (fixes #53)#54
bigspawn merged 7 commits intomainfrom
feat/preserve-dates

Conversation

@bigspawn
Copy link
Owner

Summary

Closes #53

This PR adds support for preserving start and end dates when synchronizing between MyAnimeList and AniList. Previously, manually set dates were lost during sync, or replaced with sync timestamps.

Changes

  • Added date comparison logic to detect when dates need syncing
  • Updated AniList GraphQL mutations to include startedAt and completedAt fields
  • Dates are only sent when present on source (nil dates are omitted to preserve manually-set target dates)
  • FinishedAt is only synced when status is COMPLETED (prevents infinite update loops for non-completed entries)

Behavior

Source (a) Target (b) Action
nil set keep target date (don't clear)
set nil sync date to target
same same already in sync
differ differ update target date

Test Plan

  • Unit tests for date comparison utilities
  • Unit tests for anime date sync scenarios
  • Unit tests for manga date sync scenarios
  • Manual testing with real MAL/AniList accounts

- UpdateAnimeEntry: replace prefix parameter with startedAt/completedAt
- UpdateMangaEntry: replace prefix parameter with startedAt/completedAt
- Add timeToFuzzyDateInput helper for AniList FuzzyDateInput format
- Only send dates when non-nil (omit to preserve existing manually-set dates)
- Add comprehensive doc comments explaining date handling behavior
- Add sameDates() helper for comparing date pointers at day-level granularity
- Modify SameProgressWithTarget() to compare StartedAt and FinishedAt
- Only compare FinishedAt when status is COMPLETED (prevents infinite loops)
- Modify GetStringDiffWithTarget() to include date fields in diff output
- Modify SameProgressWithTarget() to compare StartedAt and FinishedAt
- Only compare FinishedAt when status is COMPLETED (prevents infinite loops)
- Modify GetStringDiffWithTarget() to include date fields in diff output
- Modify AniListAnimeService.Update() to pass StartedAt and FinishedAt
  (only completedAt when status is COMPLETED)
- Modify AniListMangaService.Update() to pass dates
  (only completedAt when status is COMPLETED)
- Remove unused prefix parameter
- Add TestTimeToFuzzyDateInput - test nil and valid dates, edge cases
- Add TestSameDates - test all combinations of nil/set dates
- Add TestAnime_SameProgressWithTarget_Dates - comprehensive date comparison scenarios
- Add TestAnime_GetStringDiffWithTarget_Dates - verify dates appear in diff
- Add TestManga_SameProgressWithTarget_Dates - manga-specific date tests
- Add TestManga_GetStringDiffWithTarget_Dates - manga diff tests
- Add docs/date-sync.md with comprehensive date sync documentation
- Update CLAUDE.md to reference date-sync.md in components table
- Add note about date preservation in sync directions section
Remove unused jikanGo and x/time packages
@bigspawn bigspawn merged commit 57225bb into main Feb 17, 2026
3 checks passed
@bigspawn bigspawn deleted the feat/preserve-dates branch February 17, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Preserve start and end dates

1 participant