Skip to content

Overflow calculating large periods #229

Description

@GoogleCodeExporter
Can't calculate total number of days in the ISO calendar.

  var a = new LocalDate(CalendarSystem.Iso.MinYear, 1, 1);
  var b = new LocalDate(CalendarSystem.Iso.MaxYear, 12, 31);
  var period = Period.Between(a, b, PeriodUnits.Days);
  var days = period.Days;

System.OverflowException
Arithmetic operation resulted in an overflow.
   at NodaTime.Fields.FixedLengthPeriodField.GetInt64Difference(LocalInstant minuendInstant, LocalInstant subtrahendInstant)
   at NodaTime.Period.Between(LocalDateTime start, LocalDateTime end, PeriodUnits units)
   at NodaTime.Period.Between(LocalDate start, LocalDate end, PeriodUnits units)

Also tried with just C.E. dates.  Still to large to calculate.  We could either 
use a larger data type, or possibly perform the operation in smaller units 
depending on the period units specified, instead of just operating on the raw 
ticks.

Original issue reported on code.google.com by mj1856 on 26 Jul 2013 at 7:16

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions