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

fix:(module:datepicker): ArgumentOutOfRangeException in TimePicker #3501

Conversation

Alexbits
Copy link
Contributor

@Alexbits Alexbits commented Nov 8, 2023

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • Bundle size optimization
  • Performance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

#3498

💡 Background and solution

The ArgumentOutOfRangeException occurs in the TimePicker when internally converting DateTime.MinValue with DateTimeKind.Local to the DateTimeOffset. The solution is to change DateTime.Kind to Unspecified during the conversion.

📝 Changelog

Fixes System.ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset') in the TimePicker.

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

Copy link

github-actions bot commented Nov 8, 2023

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Attention: 32 lines in your changes are missing coverage. Please review.

Comparison is base (ede6b57) 44.57% compared to head (8a9b39f) 1.55%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #3501       +/-   ##
==========================================
- Coverage   44.57%   1.55%   -43.03%     
==========================================
  Files         566     566               
  Lines       26934   26899       -35     
  Branches     5582    5566       -16     
==========================================
- Hits        12005     417    -11588     
- Misses      13953   26442    +12489     
+ Partials      976      40      -936     
Files Coverage Δ
...ponents/core/Extensions/ComponentBaseExtensions.cs 0.00% <ø> (ø)
components/select/SelectBase.cs 0.00% <ø> (-68.52%) ⬇️
components/tree-select/TreeSelect.razor 0.00% <ø> (ø)
components/tree/TreeNode.razor.cs 0.00% <0.00%> (-20.64%) ⬇️
components/date-picker/internal/DatePickerBase.cs 0.00% <0.00%> (-76.93%) ⬇️
components/date-picker/internal/InternalConvert.cs 0.00% <0.00%> (-51.54%) ⬇️
components/tree-select/TreeSelect.razor.cs 0.00% <0.00%> (ø)
components/tree/Tree.razor.cs 0.00% <0.00%> (-24.52%) ⬇️

... and 259 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ElderJames
Copy link
Member

Thanks @Alexbits , but I also meet the issue.

fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'f2GWliJj68gILfJJAsyaT5tqpUZXcrwi4Tkt0lnR6yM'.
      System.ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset')
         at System.DateTimeOffset.ValidateDate(DateTime dateTime, TimeSpan offset)
         at System.DateTimeOffset..ctor(DateTime dateTime)
         at AntDesign.Internal.InternalConvert.ConvertFromDateTime(DateTime input) in D:\Github\ant-design-blazor\components\date-picker\internal\InternalConvert.cs:line 297
         at AntDesign.Internal.InternalConvert.ToDateTimeOffset[TValue](TValue input) in D:\Github\ant-design-blazor\components\date-picker\internal\InternalConvert.cs:line 53
         at AntDesign.DatePickerBase`1.ToDateTimeOffset(DateTime value, Nullable`1& currentValue, DateTimeOffset& newValue) in D:\Github\ant-design-blazor\components\date-picker\internal\DatePickerBase.cs:line 1097
         at AntDesign.DatePicker`1.ChangeValue(DateTime value, Int32 index, Boolean closeDropdown) in D:\Github\ant-design-blazor\components\date-picker\DatePicker.Razor.cs:line 218
         at AntDesign.DatePickerBase`1.OnOkClick() in D:\Github\ant-design-blazor\components\date-picker\internal\DatePickerBase.cs:line 626
         at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
         at AntDesign.Button.HandleOnClick(MouseEventArgs args) in D:\Github\ant-design-blazor\components\button\Button.razor.cs:line 167
         at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

@Alexbits
Copy link
Contributor Author

Thanks @Alexbits , but I also meet the issue.

@ElderJames Fixed. DatePicker needs more unit tests...

@ElderJames
Copy link
Member

You are right @Alexbits . Do you want to add tests in this PR or another one?

@Alexbits
Copy link
Contributor Author

You are right @Alexbits . Do you want to add tests in this PR or another one?

Added basic tests to cover this issue

Copy link
Member

@ElderJames ElderJames left a comment

Choose a reason for hiding this comment

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

LGTM

@ElderJames ElderJames merged commit ed0e864 into ant-design-blazor:master Nov 12, 2023
4 of 6 checks passed
@Alexbits Alexbits deleted the fix/timeonly_argument_out_of_range branch November 12, 2023 08:43
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.

Setting a new value on a time picker component with an already set non-null value yields an error
2 participants