Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TimeZone parameter to BitDateRangePicker (#10293) #10297

Merged

Conversation

Cyrus-Sushiant
Copy link
Member

@Cyrus-Sushiant Cyrus-Sushiant commented Mar 25, 2025

This closes #10293

Summary by CodeRabbit

  • New Features
    • Enhanced the date range picker with custom time zone support, ensuring more accurate date and time selections based on a user-defined zone.
    • Updated the demo with a new "TimeZone" example that lets users experience and compare both local and system-specified time zone configurations.

Copy link

coderabbitai bot commented Mar 25, 2025

Walkthrough

This pull request adds a new TimeZone parameter to the DateRangePicker component. A private field _timeZone (defaulting to TimeZoneInfo.Local) is introduced along with a public TimeZone property. The component’s logic is updated so that date calculations use _timeZone.GetUtcOffset(). In addition, demo pages and sample files have been modified to include and demonstrate the new timezone functionality, with updated IDs and example numbering.

Changes

File(s) Change Summary
src/BlazorUI/.../Components/Inputs/DateRangePicker/BitDateRangePicker.razor.cs Added private _timeZone field and public TimeZone parameter (with CallOnSet), updating OnSetParameters and various date calculation methods to use _timeZone.GetUtcOffset().
src/BlazorUI/Demo/Client/.../BitDateRangePickerDemo.razor Introduced a new "TimeZone" demo example by renaming the previous "Standalone" example and adjusting IDs and Razor code references.
src/BlazorUI/Demo/Client/.../BitDateRangePickerDemo.razor.cs Added a new TimeZone parameter and private fields (timeZoneDateRange1 and timeZoneDateRange2) to enable timezone-aware behavior.
src/BlazorUI/Demo/Client/.../BitDateRangePickerDemo.razor.samples.cs Added new timezone-aware examples and renumbered/renamed existing examples to reflect the updated demo structure.

Sequence Diagram(s)

sequenceDiagram
    participant U as User/Parent Component
    participant B as BitDateRangePicker
    U->>B: Set TimeZone parameter
    B->>B: CallOnSet triggers OnSetParameters()
    B-->>B: Update _timeZone (TimeZone or default local)
    B->>B: Use _timeZone.GetUtcOffset() in date calculations
Loading
sequenceDiagram
    participant DP as Demo Page
    participant P as DateRangePicker (Local)
    participant Q as DateRangePicker (System)
    DP->>DP: Retrieve available TimeZones
    DP->>P: Initialize with TimeZone = Local
    DP->>Q: Initialize with selected system TimeZone
    P->>DP: Return selected date range
    Q->>DP: Return selected date range
Loading

Assessment against linked issues

Objective Addressed Explanation
Add TimeZone parameter to BitDateRangePicker (#10293)

Poem

I'm a hopping rabbit on a coding spree,
Adjusting time with precision and glee.
With each new offset, dates now align,
In pickers and demos, the logic is fine.
Leaping through time, my code sings free! 🐰💻


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9666ad5 and 279b447.

📒 Files selected for processing (4)
  • src/BlazorUI/Bit.BlazorUI/Components/Inputs/DateRangePicker/BitDateRangePicker.razor.cs (7 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DateRangePicker/BitDateRangePickerDemo.razor (6 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DateRangePicker/BitDateRangePickerDemo.razor.cs (2 hunks)
  • src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DateRangePicker/BitDateRangePickerDemo.razor.samples.cs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build and test
🔇 Additional comments (10)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DateRangePicker/BitDateRangePickerDemo.razor.cs (2)

376-381: LGTM! TimeZone parameter is properly implemented.

The TimeZone parameter is correctly added with appropriate type, default value, and description. This aligns with other similar parameters in the component.


1020-1021: LGTM! Proper initialization of TimeZone date range fields.

The timeZoneDateRange1 and timeZoneDateRange2 fields are correctly initialized using new() to create empty BitDateRangePickerValue objects.

src/BlazorUI/Bit.BlazorUI/Components/Inputs/DateRangePicker/BitDateRangePicker.razor.cs (4)

29-29: LGTM! Private field properly defaults to the local timezone.

The _timeZone field is correctly initialized to TimeZoneInfo.Local as a sensible default.


427-432: LGTM! TimeZone parameter is properly implemented with necessary attributes.

The TimeZone parameter is correctly marked with:

  • XML documentation
  • [Parameter] attribute
  • [CallOnSet] attribute to trigger OnSetParameters when the value changes

This implementation follows the pattern used for other similar parameters in the component.


751-751: LGTM! TimeZone field is properly initialized in OnSetParameters.

The _timeZone field is correctly assigned from the TimeZone parameter with a fallback to TimeZoneInfo.Local when null.


847-847: LGTM! Consistent timezone offset application throughout the component.

All DateTimeOffset creation now uses _timeZone.GetUtcOffset() instead of DateTimeOffset.Now.Offset, ensuring that dates are consistently interpreted with the specified timezone.

Also applies to: 1435-1435, 1440-1441, 1508-1509

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DateRangePicker/BitDateRangePickerDemo.razor.samples.cs (2)

65-85: LGTM! TimeZone example is comprehensive and well-structured.

The new example demonstrates:

  1. Using the default local timezone
  2. Retrieving available system timezones
  3. Using a specific timezone with the BitDateRangePicker
  4. Displaying the selected date ranges

The example follows the established pattern and provides good code samples.


87-143: LGTM! Consistent example renumbering.

All subsequent examples are properly renumbered to accommodate the new TimeZone example, maintaining the logical flow of the documentation.

Also applies to: 145-339

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DateRangePicker/BitDateRangePickerDemo.razor (2)

131-167: LGTM! TimeZone demo is informative and well-implemented.

The TimeZone demo includes:

  1. Clear explanatory text about timezone handling
  2. Important notes about runtime considerations
  3. Link to additional documentation
  4. Practical examples with both local and system timezones
  5. Display of selected date ranges for comparison

This provides users with a comprehensive understanding of the feature.


169-319: LGTM! Consistent example renumbering in the demo page.

All subsequent example IDs and titles are properly updated to accommodate the new TimeZone example, maintaining the logical organization of the demo page.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@msynk msynk merged commit eef67d8 into bitfoundation:develop Mar 26, 2025
3 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.

Add TimeZone parameter to BitDateRangePicker component
2 participants