[BUG] Streak uses the UTC date instead of the user's local date

オープン 初心者向け
#116 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react-native, typescript
領域
mobile

調査の方向性

src/utils/stats.ts の updateStreak から始め、src/types/weekUtils.ts の getWeekId と日付の扱いを比較してください。既存の streak テストがあれば実行し、UTC+2 および UTC より西の地域で、現地時間の午前0時前後の動作を確認してください。streak の日付が現地の暦を使い、保存される YYYY-MM-DD 形式が変わらないことをもって完了とします。

索引モデルが issue の本文から書いたものです。

説明

bug gamification good first issue

Description

updateStreak in src/utils/stats.ts computes "today" and "yesterday" from new Date().toISOString(), which gives the UTC calendar date. The rest of the planner (week ids, days) uses the local date (src/types/weekUtils.ts).

For users outside UTC, activity near midnight is recorded on the wrong day:

  • In UTC+2 (e.g. Central Europe in summer), completing a block at 00:30 local time on Tuesday stores lastActiveDate as Monday.
  • Two activities at 23:30 Monday and 00:30 Tuesday local time can land on the same UTC date, so the streak is not incremented even though the user was active on two consecutive local days.
  • West of UTC the opposite happens in the evening.

Steps to reproduce

  1. Set the device timezone to UTC+2.
  2. Complete a block at 00:30 local time.
  3. lastActiveDate (AsyncStorage @levelup/last_active) holds the previous day's date.

Expected behavior

Streak days follow the user's local calendar, consistent with the planner weeks.

Suggested fix

Build the date string from local fields (getFullYear(), getMonth(), getDate()), as getWeekId already does, and compute "yesterday" the same way. Existing users' stored lastActiveDate values stay valid (same YYYY-MM-DD format).

Found while writing tests; drafted with the help of Claude Code.

主要言語
TypeScript
スター
4
フォーク
4
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

GiZano/LevelUp のほかの issue

GiZano/LevelUp の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。