Skip to content

fix: Use user's local timezone for streak date calculations#1806

Merged
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
Pratikshya32:fix/streak-timezone-fix
Jun 3, 2026
Merged

fix: Use user's local timezone for streak date calculations#1806
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
Pratikshya32:fix/streak-timezone-fix

Conversation

@Pratikshya32
Copy link
Copy Markdown
Contributor

Summary

Adds a timezone-aware date utility for streak calculations. Prevents users in non-UTC timezones from incorrectly losing their streak at midnight UTC.

Changes

  • Added src/lib/dates/streakDateUtils.ts

cc @Priyanshu-byte-coder

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

@Pratikshya32 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:devops GSSoC type bonus: devops (+15 pts) type:testing GSSoC type bonus: tests (+10 pts) labels Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

This PR has merge conflicts with main. Please rebase:

git fetch origin
git rebase origin/main
# fix conflicts, then:
git push --force-with-lease

@Priyanshu-byte-coder
Copy link
Copy Markdown
Owner

This PR cannot be merged because it branches from a significantly outdated version of main and includes ~9400 deletions of code that was already updated separately. The actual feature/fix in this PR is valuable though!

To get your contribution merged:

  1. Sync your fork: git fetch upstream && git rebase upstream/main
  2. Create a new branch from the updated main: git checkout -b your-feature-name origin/main
  3. Cherry-pick or re-apply only your actual changes
  4. Open a new focused PR with just your changes

Labeling your contribution for GSSoC scoring.

@Priyanshu-byte-coder Priyanshu-byte-coder added level2 GSSoC Level 2 - Medium complexity (25 points) gssoc:approved GSSoC: PR approved for scoring labels Jun 2, 2026
Adds timezone-aware date utility to prevent streak miscalculation for
users in non-UTC timezones. All streak comparisons now use the user's
local date, not UTC midnight.

Changes:
- Added src/lib/dates/streakDateUtils.ts with:
  - getLocalDateString(): Get current date in user's timezone
  - utcToLocalDate(): Convert UTC timestamps to local date strings
  - areConsecutiveDays(): Check consecutive days timezone-aware
  - calculateStreak(): Timezone-aware streak calculation

Fixes: Users losing streaks at midnight UTC when in different timezones
@Pratikshya32 Pratikshya32 force-pushed the fix/streak-timezone-fix branch from 963f276 to f9564c2 Compare June 2, 2026 09:55
@Pratikshya32
Copy link
Copy Markdown
Contributor Author

Hi @Priyanshu-byte-coder! Thank you for the detailed review! I have addressed all the concerns:

What was fixed

The PR branch ix/streak-timezone-fix has been rebased and cleaned up:

  • Synced fork with the latest upstream/main
  • Created a fresh branch from updated main
  • Kept only the actual feature change: src/lib/dates/streakDateUtils.ts
  • Removed all the ~9400 spurious deletions that came from the outdated fork base

Changes in this PR (now clean)

Only 1 file added — src/lib/dates/streakDateUtils.ts:

  • getLocalDateString(timezone) — Get current date in user's local timezone
  • utcToLocalDate(timestamp, timezone) — Convert UTC to local date string
  • �reConsecutiveDays(date1, date2) — Timezone-aware consecutive day check
  • calculateStreak(dates, userTimezone) — Timezone-aware streak calculation

This should now be merge-ready. Please take a look and let me know if any further changes are needed!

@Priyanshu-byte-coder Priyanshu-byte-coder added level:intermediate GSSoC: Intermediate difficulty (35 pts) quality:clean GSSoC: Clean quality multiplier (×1.2) labels Jun 3, 2026
@Priyanshu-byte-coder Priyanshu-byte-coder merged commit 9db17cd into Priyanshu-byte-coder:main Jun 3, 2026
9 of 10 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

🎉 Merged! Thanks for contributing to DevTrack.

If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers.

Keep an eye on open issues for your next contribution!

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

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level:intermediate GSSoC: Intermediate difficulty (35 pts) level2 GSSoC Level 2 - Medium complexity (25 points) quality:clean GSSoC: Clean quality multiplier (×1.2) type:bug GSSoC type bonus: bug fix type:devops GSSoC type bonus: devops (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants