我有一些NodaTime代码正在查看区域间隔:
var zone = DateTimeZoneProviders.Tzdb["America/Phoenix"];
var interval = zone.GetZoneInterval(SystemClock.Instance.Now);
Console.WriteLine(interval.End);
Console.WriteLine(interval.IsoLocalEnd);
interval.End
输出EOT
,这是预期的,因为此区域不使用夏令时。但我无法输出interval.IsoLocalEnd
值。它引发了一个例外:
System.ArgumentOutOfRangeException was unhandled
HResult=-2146233086
Message=Value should be in range [-27255-31195]
Parameter name: year
Actual value was 31197.
Source=NodaTime
ParamName=year
StackTrace:
at NodaTime.Utility.Preconditions.CheckArgumentRange(String paramName, Int32 value, Int32 minInclusive, Int32 maxInclusive)
at NodaTime.Calendars.BasicCalendarSystem.GetYearTicks(Int32 year)
at NodaTime.Calendars.GregorianCalendarSystem.GetYearTicks(Int32 year)
at NodaTime.Calendars.BasicGJCalendarSystem.GetMonthOfYear(LocalInstant localInstant, Int32 year)
at NodaTime.Calendars.BasicCalendarSystem.GetMonthOfYear(LocalInstant localInstant)
at NodaTime.Fields.BasicMonthOfYearDateTimeField.GetValue(LocalInstant localInstant)
at NodaTime.LocalDateTime.get_Month()
at NodaTime.Text.LocalDateTimePatternParser.<.cctor>b__8(LocalDateTime value)
at NodaTime.Text.Patterns.DatePatternHelper.<>c__DisplayClassd`2.<>c__DisplayClass10.<CreateMonthOfYearHandler>b__c(TResult value, StringBuilder sb)
at NodaTime.NodaAction`2.Invoke(TArg1 arg1, TArg2 arg2)
at NodaTime.Text.Patterns.SteppedPatternBuilder`2.SteppedPattern.Format(TResult value)
at NodaTime.Text.Patterns.PatternBclSupport`1.Format(T value, String patternText, NodaFormatInfo formatInfo)
at NodaTime.LocalDateTime.ToString(String patternText, IFormatProvider formatProvider)
at System.IO.TextWriter.WriteLine(Object value)
at System.IO.TextWriter.SyncTextWriter.WriteLine(Object value)
这是一个错误吗?或者这是预期的行为,我应该在尝试使用interval.End == Instant.MaxValue
值之前检查interval.IsoLocalEnd
吗?
我正在使用NodaTime 1.1.0。