Skip to content

fix(news-widget): enforce strict UTC date parsing to prevent timezone…#1366

Merged
regulartim merged 1 commit into
GreedyBear-Project:developfrom
suvani-ctrl:fix/1362-news-widget-timezone-override
May 26, 2026
Merged

fix(news-widget): enforce strict UTC date parsing to prevent timezone…#1366
regulartim merged 1 commit into
GreedyBear-Project:developfrom
suvani-ctrl:fix/1362-news-widget-timezone-override

Conversation

@suvani-ctrl
Copy link
Copy Markdown
Contributor

@suvani-ctrl suvani-ctrl commented May 24, 2026

Description

This PR fixes a bug where the NewsWidget displays the wrong date for users in Western timezones (for example, showing "31st Dec 2023" instead of "2024-01-01").

The app was using the user's local computer time to read a UTC date string. The bug was fixed by forcing the code to use UTC everywhere (getUTCDate() and timeZone: "UTC"). Now, everyone sees the exact same correct date no matter where they live.

Related issues

Closes #1362

Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Chore (refactoring, dependency updates, CI/CD changes, code cleanup, docs-only changes).

Checklist

Please complete this checklist carefully. It helps guide your contribution and lets maintainers verify that all requirements are met.

Formalities

  • I have read and understood the rules about how to Contribute to this project.
  • I chose an appropriate title for the pull request in the form: <feature name>. Closes #999
  • My branch is based on develop.
  • The pull request is for the branch develop.
  • I have reviewed and verified any LLM-generated code included in this PR.

Docs and tests

  • I documented my code changes with docstrings and/or comments.
  • I have checked if my changes affect user-facing behavior that is described in the docs. If so, I also included an update to the wiki in the description of this PR.
  • Linter (Ruff) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved.
  • All the tests gave 0 errors.

GUI changes

Ignore this section if you did not make any changes to the GUI.

  • I have provided a screenshot of the result in the PR.
  • [] I have created new frontend tests for the new component or updated existing ones.

Review process

  • We encourage you to create a draft PR first, even when your changes are incomplete. This way you refine your code while we can track your progress and actively review and help.
  • If you think your draft PR is ready to be reviewed by the maintainers, click the corresponding button. Your draft PR will become a real PR.
  • If your changes decrease the overall tests coverage (you will know after the Codecov CI job is done), you should add the required tests to fix the problem.
  • Every time you make changes to the PR and you think the work is done, you should explicitly ask for a review. After receiving a "change request", address the feedback and click "request re-review" next to the reviewer's profile picture at the top right.

@suvani-ctrl suvani-ctrl force-pushed the fix/1362-news-widget-timezone-override branch from 88fb795 to 15640f7 Compare May 24, 2026 07:27
@suvani-ctrl
Copy link
Copy Markdown
Contributor Author

Hello @regulartim Can you check my pr please !

@regulartim regulartim marked this pull request as ready for review May 25, 2026 05:58
Copy link
Copy Markdown
Member

@regulartim regulartim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @suvani-ctrl ! Your fix is correct and well implemented, as far as I can see. Good work! :)
An explicit regression test that forces a non-UTC TZ (like via process.env.TZ = "America/Los_Angeles") would be a good addition. This test should deterministically fail without your fix but pass when the fix is in place.

@suvani-ctrl suvani-ctrl marked this pull request as draft May 25, 2026 19:51
@suvani-ctrl suvani-ctrl force-pushed the fix/1362-news-widget-timezone-override branch from 15640f7 to b9e831f Compare May 26, 2026 06:57
@suvani-ctrl
Copy link
Copy Markdown
Contributor Author

Hello @regulartim I updated the production code and added the regression test based on your feedback. The fix now forces the news widget to use explicit UTC parsing (getUTCDate() and timeZone: "UTC").. so everyone sees the exact same threat intel dates regardless of their location.

For the regression test, I temporarily mocked the timezone inside the code using process.env.TZ = "America/Los_Angeles" and also cleaned it up in a finally block. I also avoided putting this timezon in a global .env file because changing the timezone globally would break other tests. I verified locally that this new test fails without my fix and passes when the fix is there. All 16 tests seems to pass on mine with my fixes and fail without those fixes. I have attached screenshots for better understandings . Please let me know if this is okay or not.

---> Test Failing before utc updates

failed_test

-----> Test passing after utc update
test_pass

@suvani-ctrl suvani-ctrl marked this pull request as ready for review May 26, 2026 07:06
Copy link
Copy Markdown
Member

@regulartim regulartim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you! 👍

@regulartim regulartim merged commit 8784b2d into GreedyBear-Project:develop May 26, 2026
5 checks passed
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