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

Đang mở Phù hợp với người mới
#116 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react-native, typescript
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu tại src/utils/stats.ts, ở updateStreak, rồi so sánh cách xử lý ngày tháng với getWeekId trong src/types/weekUtils.ts. Chạy các bài kiểm thử streak hiện có, nếu có, và kiểm tra hành vi quanh nửa đêm theo giờ địa phương tại UTC+2 và phía tây UTC. Hoàn thành khi ngày của streak sử dụng lịch địa phương và định dạng YYYY-MM-DD được lưu vẫn không thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
4
Fork
4
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của GiZano/LevelUp

Tất cả issue của GiZano/LevelUp

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.