You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/07/22 11:56:15 UTC
[PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
rusackas opened a new pull request, #42308:
URL: https://github.com/apache/superset/pull/42308
### SUMMARY
The custom time range's "Now"/"Midnight" options resolve through `dttmToDayjs`, which forced `now`/`today` into UTC before formatting them into a naive datetime string with no offset. That same naive string gets re-parsed elsewhere in the module as local time, so switching from "Now" to a specific date/time (or from "Anchor to: Now" to a specific anchor) drifted by the browser's UTC offset. That's the mismatch several users reported on #30627: the resolved value is off by their timezone offset instead of reflecting the actual current moment.
This drops the forced `.utc()` call so `now`/`today` resolve in local time, matching the naive string's later local re-parse.
I added a test first (`dateParser.test.ts`) pinning the bug with a fixed non-UTC timezone before making the fix.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A, this is a data/logic fix, not a visual change.
### TESTING INSTRUCTIONS
`npm run test -- dateParser.test.ts` from `superset-frontend/`. Both new tests fail against the old `.utc()`-forced code and pass after the fix.
Manually: with a browser timezone other than UTC, pick a custom time range, set Start to "Now", then switch it to "Specific Date/Time". The date/time picker should now show the actual current local time instead of one offset by your UTC difference.
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #30627
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #42308:
URL: https://github.com/apache/superset/pull/42308#issuecomment-5081012644
### <span aria-hidden="true">β
</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">π¨</span> Latest commit | adb501a77c95d22fc749e63d61dcbd70f95d1f8d |
|<span aria-hidden="true">π</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a6544cda32b35000840b415 |
|<span aria-hidden="true">π</span> Deploy Preview | [https://deploy-preview-42308--superset-docs-preview.netlify.app](https://deploy-preview-42308--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">π±</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">π€</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DYtJDoMwDAD_4nOtumRp1R_0GQkxNBIlVhIkEOLv9WU0c5gTpJafdHgD3CDWsI5f9Snv99zaxmjID09s2zxz65ywCK8oFbsmTrkqo56JZSnHJ-nrg3fWjimYIRpHRC9L0T4cXH8) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-42308--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #42308:
URL: https://github.com/apache/superset/pull/42308#discussion_r3651262778
##########
superset-frontend/src/explore/components/controls/DateFilterControl/utils/dateParser.ts:
##########
@@ -40,11 +40,18 @@ export const ISO8601_AND_CONSTANT = RegExp(
const SPECIFIC_MODE = ['specific', 'today', 'now'];
export const dttmToDayjs = (dttm: string): Dayjs => {
+ // "now"/"today" are later formatted (see dttmToString) into a naive
+ // "YYYY-MM-DDTHH:mm:ss" string with no UTC offset, and that string is
+ // re-parsed elsewhere as local time (the `extendedDayjs(dttm)` fallback
+ // below). Resolving these constants in UTC rather than local time would
+ // make that round trip drift by the browser's UTC offset, which is what
+ // caused the "Now" anchor to display and query the wrong wall-clock time
+ // for users outside UTC.
if (dttm === 'now') {
- return extendedDayjs().utc().startOf('second');
+ return extendedDayjs().startOf('second');
Review Comment:
Added a note to UPDATING.md flagging the change. Gating it to charts saved after this lands isn't really doable though, "now"/"today" are stored as the literal strings and resolved fresh every time the chart runs, there's no saved timestamp to version against. So it's really just a bug fix landing for everyone at once, hand-wavy UPDATING.md note is probably the best we can do here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42308:
URL: https://github.com/apache/superset/pull/42308#issuecomment-5073680267
<!-- Bito Reply -->
Changing the behavior of date constants like 'now' and 'today' to use local time instead of UTC is a significant shift. To manage this transition, consider the following approaches:
* **Documentation and Communication:** Update `UPDATING.md` or release notes to explicitly warn users about the change in behavior. This allows dashboard owners to verify if their existing filters or charts are affected by the shift from UTC to local time.
* **Versioned Behavior:** If possible, introduce a flag or versioning for dashboard configurations. This would allow existing charts to maintain their current behavior while new charts or those explicitly updated by users adopt the new local-time logic, avoiding breaking changes for legacy dashboards.
* **Migration Script:** Provide a migration utility that identifies dashboards using these constants and allows owners to opt-in to the new behavior, ensuring they can test the impact before finalizing the change.
**superset-frontend/src/explore/components/controls/DateFilterControl/utils/dateParser.ts**
```
if (dttm === 'now') {
return extendedDayjs().startOf('second');
}
if (dttm === 'today') {
return extendedDayjs().startOf('day');
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #42308:
URL: https://github.com/apache/superset/pull/42308
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #42308:
URL: https://github.com/apache/superset/pull/42308#issuecomment-5045474998
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on code in PR #42308:
URL: https://github.com/apache/superset/pull/42308#discussion_r3647721531
##########
superset-frontend/src/explore/components/controls/DateFilterControl/utils/dateParser.ts:
##########
@@ -40,11 +40,18 @@ export const ISO8601_AND_CONSTANT = RegExp(
const SPECIFIC_MODE = ['specific', 'today', 'now'];
export const dttmToDayjs = (dttm: string): Dayjs => {
+ // "now"/"today" are later formatted (see dttmToString) into a naive
+ // "YYYY-MM-DDTHH:mm:ss" string with no UTC offset, and that string is
+ // re-parsed elsewhere as local time (the `extendedDayjs(dttm)` fallback
+ // below). Resolving these constants in UTC rather than local time would
+ // make that round trip drift by the browser's UTC offset, which is what
+ // caused the "Now" anchor to display and query the wrong wall-clock time
+ // for users outside UTC.
if (dttm === 'now') {
- return extendedDayjs().utc().startOf('second');
+ return extendedDayjs().startOf('second');
Review Comment:
This is "more right", but it's also a change in behavior ... wondering how many dashboards there are out there that already compensate for the current behavior in some way.
Question is how to handle the change in behavior?
- hand wavy in UPDATING.md?
- only apply to charts saved after this change? -> tech-debty, might prevent desired fixes, ...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
Posted by "prathamesh04 (via GitHub)" <gi...@apache.org>.
prathamesh04 commented on PR #42308:
URL: https://github.com/apache/superset/pull/42308#issuecomment-5053259982
@sadpandajoe This PR is ready for review. Please review when you have a chance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): resolve now/today anchors to local time, not UTC [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #42308:
URL: https://github.com/apache/superset/pull/42308#issuecomment-5081036164
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/42308?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 65.15%. Comparing base ([`6e1954f`](https://app.codecov.io/gh/apache/superset/commit/6e1954fd51ce7334bf7c66526a616eca1f15768c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`adb501a`](https://app.codecov.io/gh/apache/superset/commit/adb501a77c95d22fc749e63d61dcbd70f95d1f8d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 81 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #42308 +/- ##
=======================================
Coverage 65.15% 65.15%
=======================================
Files 2789 2789
Lines 157572 157546 -26
Branches 35872 35866 -6
=======================================
- Hits 102662 102648 -14
+ Misses 52939 52930 -9
+ Partials 1971 1968 -3
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/42308/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Ξ | |
|---|---|---|
| [javascript](https://app.codecov.io/gh/apache/superset/pull/42308/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `71.07% <100.00%> (ΓΈ)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/42308?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org