Skip to content

ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime. #478

@heran99

Description

@heran99

某些时区的用户在运行软件时,调用ExcelReaderFactory.CreateReader时会遇到错误。目前所知道的有“澳大利亚悉尼”时区。其他待测试。发现问题只存在于Windos系统。以下为机器翻译
The following is machine translation:
When users in some time zones run the software, they will encounter errors when calling ExcelReaderFactory.CreateReader.
The time zone known as "Sydney Australia" is currently known.Other to be tested.
Found that the problem only exists in the Windos system.

问题似乎出在CompoundDocument.cs中第170行 DateTime.MaxValue.ToFileTime()
The problem seems to be at line 170 in CompoundDocument.cs DateTime.MaxValue.ToFileTime()

因为我找到了这个:
Because I found this:“Some calendars, such as the ThaiBuddhistCalendar, support an upper date range that is earlier than MaxValue. In these cases, trying to access MaxValue in variable assignments or formatting and parsing operations can throw an ArgumentOutOfRangeException. Rather than retrieving the value of DateTime.MaxValue, you can retrieve the value of the specified culture's latest valid date value from the Calendar.MaxSupportedDateTime property.”
出自(https://docs.microsoft.com/en-us/dotnet/api/system.datetime.maxvalue?view=netcore-3.1)

以下是用户提供的output Log:
The following is the output Log provided by the user:
ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime. at System.DateTime.DateToTicks (System.Int32 year, System.Int32 month, System.Int32 day) [0x00077] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.DateTime..ctor (System.Int32 year, System.Int32 month, System.Int32 day) [0x00000] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.TimeZoneInfo.TransitionPoint (System.TimeZoneInfo+TransitionTime transition, System.Int32 year) [0x0003a] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.TimeZoneInfo.IsInDSTForYear (System.TimeZoneInfo+AdjustmentRule rule, System.DateTime dateTime, System.Int32 year) [0x00030] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.TimeZoneInfo.IsInDST (System.TimeZoneInfo+AdjustmentRule rule, System.DateTime dateTime) [0x0000a] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.TimeZoneInfo.GetUtcOffsetHelper (System.DateTime dateTime, System.TimeZoneInfo tz, System.Boolean& isDST) [0x000ce] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.TimeZoneInfo.GetUtcOffset (System.DateTime dateTime, System.Boolean& isDST) [0x00025] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.TimeZoneInfo.ConvertTimeToUtc (System.DateTime dateTime, System.TimeZoneInfo sourceTimeZone, System.TimeZoneInfoOptions flags) [0x0006d] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.TimeZoneInfo.ConvertTimeToUtc (System.DateTime dateTime, System.TimeZoneInfoOptions flags) [0x00006] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.DateTime.ToUniversalTime () [0x00000] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at System.DateTime.ToFileTime () [0x00000] in <c6bd535f6ab848b4a13f34d01b756eef>:0 at ExcelDataReader.Core.CompoundFormat.CompoundDocument.ReadFileTime (System.IO.BinaryReader reader) [0x0000d] in <3d0859e5b4fe4a439976792bf0ef6ebf>:0 at ExcelDataReader.Core.CompoundFormat.CompoundDocument.ReadDirectoryEntry (System.IO.BinaryReader reader) [0x000ab] in <3d0859e5b4fe4a439976792bf0ef6ebf>:0 at ExcelDataReader.Core.CompoundFormat.CompoundDocument.ReadDirectoryEntries (System.Byte[] bytes) [0x0001e] in <3d0859e5b4fe4a439976792bf0ef6ebf>:0 at ExcelDataReader.Core.CompoundFormat.CompoundDocument..ctor (System.IO.Stream stream) [0x000e6] in <3d0859e5b4fe4a439976792bf0ef6ebf>:0 at ExcelDataReader.ExcelReaderFactory.CreateReader (System.IO.Stream fileStream, ExcelDataReader.ExcelReaderConfiguration configuration) [0x00044] in <3d0859e5b4fe4a439976792bf0ef6ebf>:0

经过试验,用户只要打开Windows的系统设置,更改为其他时区,就可以正常运行。这个问题我们是否能够解决?谢谢!
After testing, users only need to open the Windows system settings and change to another time zone, and it can run normally. Can we solve this problem?
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions