joda-time icon indicating copy to clipboard operation
joda-time copied to clipboard

Constructing a period from partials fails when partial is a [dayOfYear = 366]

Open dm3 opened this issue 12 years ago • 4 comments

Not sure if this is supposed to fail. Probably not, as the year isn't known.

new Period(new Partial(DateTimeFieldType.dayOfYear(), 200), new Partial(DateTimeFieldType.dayOfYear(), 366));
// IllegalFieldValueException Value 366 for dayOfYear must be in the range [1,365]
//  org.joda.time.field.FieldUtils.verifyValueBounds (FieldUtils.java:218)
//  org.joda.time.field.PreciseDurationDateTimeField.set (PreciseDurationDateTimeField.java:79)
//  org.joda.time.chrono.BaseChronology.set (BaseChronology.java:240)
//  org.joda.time.base.BasePeriod.<init> (BasePeriod.java:182)
//  org.joda.time.Period.<init> (Period.java:562)

dm3 avatar Nov 26 '13 12:11 dm3

Probably a bug, but may be hard to fix

jodastephen avatar Nov 26 '13 13:11 jodastephen

This will be nigh on impossible to fix I think.

jodastephen avatar Nov 27 '13 12:11 jodastephen

@jodastephen Should this issue be closed then?

gauravsak avatar Aug 30 '16 10:08 gauravsak

@jodastephen If only 1970 was a leap year, this error would not have occurred. And, if January 1970 had less than 31 days, even: new Period(new Partial(DateTimeFieldType.dayOfMonth(),20),new Partial(DateTimeFieldType.dayOfMonth(),31)); would fail.

akarsh-jain avatar Dec 06 '17 13:12 akarsh-jain