Skip to content

fix(dashboard): send chart ranges with one UTC offset across DST - #989

Merged
T3ST3ST3R0N merged 1 commit into
PasarGuard:devfrom
mark-avd:fix/chart-range-dst
Oct 10, 2026
Merged

T3ST3ST3R0N merged 1 commit into
PasarGuard:devfrom
mark-avd:fix/chart-range-dst

Conversation

@mark-avd

@mark-avd mark-avd commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

validate_dates rejects a range whose start and end have different UTC offsets ("Start and end dates must have the same timezone", 400). The dashboard formats each bound in its own local offset, so in time zones with DST every statistics chart fails for "All time" whenever today's offset differs from the one on 2000-01-01 (summer time in Europe, winter in Sydney), and for ranges that cross a DST change (for example "1m" in late October in Europe, or "1w" in Sydney during the first week of October).

Chart query ranges are now sent with one offset, the end's:

  • Day-bounded ranges start at midnight of the start day in that offset (2000-01-01T00:00:00+02:00), so the first day bucket stays complete; get_complete_period_start_for_filter would otherwise round a shifted start up to the next day. This also covers days without a local midnight (America/Santiago, America/Havana, Asia/Beirut), where startOf('day') is 01:00 and the first day was dropped before as well.
  • Hour-bounded ranges keep the exact start instant, converted through UTC (dayjs utcOffset(n) shifts by local time and lands an hour late across the spring change).
  • getDateRangeForPeriodOption (node stats area chart) uses the same rule.
  • Custom ranges always cover whole picked days. Before, hour- and minute-period custom ranges (picks of up to 2 days, or any pick with an hour/minute override) ended at local midnight of the last picked day and dropped it, and a single clicked day could give a zero-length range or "Start date must be before end date".

Shortcuts and period options that do not cross a DST change produce the same strings as before.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / cleanup
  • Documentation
  • Tests / CI

Checklist

  • I tested the change locally or explained why it cannot be tested.
  • I added or updated tests for behavior changes. (the dashboard has no unit-test runner; checked with a script, see Testing)
  • I updated documentation, translations, or examples if needed. (none needed)
  • I checked database migrations when models or schema changed. (none)
  • I did not include secrets, tokens, private keys, or unrelated changes.

Testing

Validation Result
Bun script importing chart-period-utils.ts and the dev copy with TZ = Europe/Berlin (Mar 29, Apr 10, Oct 9, Nov 5), Australia/Sydney, America/New_York (Mar 8), America/Santiago, America/Havana, Asia/Beirut, Asia/Tehran, Asia/Kathmandu, UTC; shortcuts 1h/24h/1w/1m/all, custom ranges, period options 418 cases: one offset per range; day-bounded starts at 00:00 of the start day, hour-bounded starts at the exact instant; shortcuts and period options that do not cross DST identical to dev
Local panel, browser in Europe/Berlin, "All time" on the traffic usage chart 200 (was 400)
eslint --quiet on touched files, vite build OK

Screenshots

Not applicable.

Notes for reviewers

  • The backend buckets a range in one offset, so for a range that crosses DST the days and hours before the change are bucketed and labelled one hour off (in the end's offset). Before this change such ranges returned 400; per-bucket DST handling would need a backend change.
  • formatOffsetStartOfDay had no callers left and is removed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved chart date-range handling across time zones, keeping start and end dates aligned to the intended offset.
    • Day- and month-based chart ranges now consistently cover the full selected days, including when ranges are built from manually selected dates. Hour-based ranges continue to use precise timestamps.

- Fix 400 "Start and end dates must have the same timezone" on All time and DST-crossing ranges
- Keep the first day bucket complete and cover whole picked days in custom ranges
@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 822fb95e-73a9-42a2-b813-9daf66b4305d

📥 Commits

Reviewing files that changed from the base of the PR and between d94e157 and f7dac17.


📒 Files selected for processing (2)
  • dashboard/src/utils/chart-period-utils.ts
  • dashboard/src/utils/dateTimeParsing.ts

💤 Files with no reviewable changes (1)
  • dashboard/src/utils/dateTimeParsing.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.



Walkthrough

Chart date range utilities now format start timestamps using the end timestamp’s UTC offset. Day and month query ranges use day boundaries, and input date ranges are normalized before query range construction.

Changes

Chart date range formatting

Layer / File(s) Summary
Period range formatting
dashboard/src/utils/chart-period-utils.ts, dashboard/src/utils/dateTimeParsing.ts
A new helper formats start timestamps using the end timestamp’s UTC offset. Period ranges use this helper, and the exported formatOffsetStartOfDay helper is removed.
Query range normalization
dashboard/src/utils/chart-period-utils.ts
Day and month bounds use start-of-day and end-of-day timestamps. Date range inputs are normalized to day boundaries before building the query range.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: x0sina

Merge Risk: ⚪ Minimal · up to f7dac

Chart ranges now use a consistent offset across DST, and the inspected API handling is compatible with those bounds. No new merge-blocking behavior is established.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: using one UTC offset for dashboard chart ranges that cross daylight-saving transitions.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the dates at dawn
The start is shifted, then placed upon
The end’s own offset guides the way
Day bounds hold the chart at bay
The rabbit hops through ranges neat

Comment @coderabbitai help to get the list of available commands.

@T3ST3ST3R0N
T3ST3ST3R0N merged commit 795dc70 into PasarGuard:dev Oct 10, 2026
4 checks passed
@mark-avd
mark-avd deleted the fix/chart-range-dst branch October 11, 2026 12:07
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 2, 2026
…ain bba95f274

Checked with git ls-remote on 2026-10-11 02:55 UTC. Panel dev moved from
d94e157 to 83fe90e with 22 commits; main is still v5.4.1.

- PasarGuard#879 (2d0ca81, loopback Xray client inbounds) is ported by design: the
  fork took the open pull request on 2026-09-25 as 2e7fc45 with migration
  bfd88026565b, the same listener rewrite.
- PasarGuard#934 (a5b28f3) moves from the port queue to a dated waiver until
  2026-11-09: the fork refuses to delete a core that nodes still use
  (W3-013, fix/node-health) instead of restarting those nodes.
- PasarGuard#993 (Hysteria2 FinalMask without a udp mask) is queued until 2026-10-18:
  the fork has the same FinalMask | dict field and the same non-null-safe
  udpHop reads, so a udpHop-only host can fail the whole subscription.
- PasarGuard#984, PasarGuard#985, PasarGuard#986, PasarGuard#989, PasarGuard#944, PasarGuard#864, PasarGuard#948, PasarGuard#951, PasarGuard#778, PasarGuard#774, PasarGuard#787, PasarGuard#994,
  PasarGuard#865, PasarGuard#875, PasarGuard#718, PasarGuard#967, PasarGuard#772, PasarGuard#662, PasarGuard#995 and PasarGuard#913 are queued as
  security: no until 2026-10-25, each with its reason; PasarGuard#913's node-removal
  half is already in the fork through sync_remove_users.
- The branch commits that upstream squash-merged (the three dashboard
  branches, telegram/tests, fix/core-editor-api-section-followup,
  fix/hwid-count-test-cleanup, fix/hysteria-finalmask-quic-only) follow
  their squash, by patch-id or by an equal tree.

Scripts main moved to bba95f274 (PasarGuard#35, PasarGuard#36, PasarGuard#37 after PasarGuard#34). The three
squashes are queued security: no until 2026-10-25, and their pre-squash
branch commits are waived as superseded (equal trees).

Against live upstream the panel gate now fails only on the 17 port-queue
commits classified security: yes, and the forks gate only on node
f72ac0ef (security: yes). No upstream commit is undecided.
Free-Guy-IR pushed a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
…arGuard#989)

- Fix 400 "Start and end dates must have the same timezone" on All time and DST-crossing ranges
- Keep the first day bucket complete and cover whole picked days in custom ranges

(cherry picked from commit 795dc70)
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.

2 participants