Skip to content

Conversation

@avazirna
Copy link
Contributor

@avazirna avazirna commented Jun 27, 2025

Product Description

This PR fixes an issue with the Nepali Date Widget in which the date decreases when the user navigates to the next question. From my investigation, I noticed that this is due to the way the timezone offset is calculated, specifically about employing methods that are not DST-aware and calculating timezone offset from a non-Gregorian calendar.
This is the behavior this PR addresses:

Video.2025-03-27.at.8.22.50.PM.mp4

Ticket: https://dimagi.atlassian.net/browse/SAAS-12013

Technical Summary

Safety Assurance

Safety story

Special deploy instructions

  • This PR can be deployed after merge with no further considerations.

Rollback instructions

  • This PR can be reverted after deploy with no further considerations.

Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change.

Duplicate PR

Automatically duplicate this PR as defined in contributing.md.

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of date and time conversions by using full timezone rules instead of fixed offsets. This ensures more reliable handling of timezones, especially for regions with daylight saving time changes.

@coderabbitai
Copy link

coderabbitai bot commented Jun 27, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes update timezone handling in calendar date conversions. The code now constructs timezone objects using full timezone rules instead of fixed offsets and adjusts offset calculations to reference the absolute epoch time. No public API signatures were altered.

Changes

File(s) Change Summary
src/main/java/org/javarosa/xform/util/CalendarUtils.java Modified timezone object creation to use full timezone data; adjusted timezone offset calculations for accuracy.

Poem

In the warren of time, a rabbit did see,
That clocks and their zones need more accuracy.
From fixed to the flowing, the offsets now dance,
With full timezone wisdom, dates get a new chance.
So hop, little code, through the daylight and night—
Your moments now handled just right!
🕰️🐇

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-nepali-date-widget-bug

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@avazirna avazirna marked this pull request as ready for review July 2, 2025 12:56
@avazirna avazirna added this to the 2.58 milestone Jul 2, 2025
@avazirna avazirna force-pushed the fix-nepali-date-widget-bug branch from 8731ceb to dcf459c Compare July 15, 2025 07:55
@Jignesh-dimagi
Copy link

@avazirna Is that right understanding that there was error when converting Gregorian/English date to Nepali date and this was recursive due to moving back and forth? If this is the case, how it was calculating correctly from Nepali to Gregorian/English date?

@avazirna
Copy link
Contributor Author

@avazirna Is that right understanding that there was error when converting Gregorian/English date to Nepali date and this was recursive due to moving back and forth? If this is the case, how it was calculating correctly from Nepali to Gregorian/English date?

@Jignesh-dimagi the issue was when converting from Nepali date to Gregorian.

@shubham1g5
Copy link
Contributor

@avazirna Looks like tests are failing on this PR.

@avazirna
Copy link
Contributor Author

@avazirna Looks like tests are failing on this PR.

@shubham1g5 fixed - e831bea


// millis <=> date is different in every timezone
@Test
public void testConvertToNepaliString() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you confirm these tests are failing without the changes made in CalendarUtils (I tried on my end but it seems to pass) ? I think we want to confirm that this test indeed reproduces the error we are trying to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shubham1g5 the tests were considering the raw offset, which doesn't account for DST. I have updated them 334a900. Can you test this again?

@avazirna avazirna requested a review from shubham1g5 July 23, 2025 08:59
@avazirna avazirna changed the base branch from master to commcare_2.58 July 25, 2025 16:48
@avazirna avazirna merged commit 2518d13 into commcare_2.58 Jul 25, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants