Re: [threeten-develop] LocalPeriod/LocalDate arithmetic properties
Status: Alpha
Brought to you by:
scolebourne
From: Douglas S. <dou...@or...> - 2012-09-06 22:55:14
|
The negated one is what Roger asked about. The two checks are not necessarily equivalent without some premises on the behavior of negated. I'd say my question is the simplest definition of negated, so no they aren't equivalent. Douglas At 03:33 PM 9/6/2012, Stephen Colebourne wrote: >Quick answer, I don't know without looking at lots of examples. I >don't immediately think that the negated check is as important as >the >one I posted, but I also suspect that the two checks may in fact be >equivalent. >Stephen > >On 6 September 2012 23:30, Douglas Surber ><dou...@or...> wrote: > > Is it required that > > > > ISOPeriod.between(start, end).equals(ISOPeriod.between(end, > > start).negated()) > > > > Douglas > > > > > > At 03:09 PM 9/6/2012, Stephen Colebourne wrote: > >>The following is required to be true (pseudo code): > >> > >>LocalDate start > >>LocalDate end > >> > >>ISOPeriod period = ISOPeriod.between(start, end); > >>LocalDate sum = start.plus(period) > >>assert sum == end > >> > >>AFAIK, this should apply whether or not start is before or after > >>end. > >>Stephen > >> > >> > >>On 6 September 2012 22:18, Roger Riggs <Rog...@or...> > >>wrote: > >> > It is likely related to different number of days in the > starting > >> and ending > >> > months. > >> > Its bug, because for the earlier month it should be counting > the > >> days left > >> > in the month > >> > and for the later month it should be counting days since the > >> start of the > >> > the month. > >> > The current code computes it using the start and ending > >> arguments, not the > >> > earlier/later date. > >> > > >> > I'll fix it. > >> > > >> > > >> > ld1: 2010-03-30 > >> > ld2: 2011-05-01 > >> > diff12: P1Y1M1D > >> > diff21: P-1Y-1M-2D > >> > negated diff21: P1Y1M2D > >> > > >> > @Test() > >> > public void test_between() { > >> > LocalDate ld1 = LocalDate.of(2010, 3, 30); > >> > LocalDate ld2 = LocalDate.of(2011, 5, 1); > >> > LocalPeriod diff12 = LocalPeriod.between(ld1, ld2); > >> > LocalPeriod diff21 = LocalPeriod.between(ld2, ld1); > >> > System.out.printf("ld1: %s%nld2: %s%ndiff12: > %s%ndiff21: > >> %s%nnegated > >> > diff21: %s%n%n", ld1, ld2, diff12, diff21, diff21.negated()); > >> > > >> > } > >> > > >> > > >> > On 09/06/2012 04:34 PM, Douglas Surber wrote: > >> > > >> > Let me be sure I understand. You are saying that > >> > > >> > LocalDate ld1 = ... ; > >> > LocalDate ld2 = ... ; > >> > Period p1 = ld1.difference(ld2); > >> > Period p2 = ld2.difference(ld1); > >> > System.out.println( ld1.equals(ld2.negated()) ); > >> > > >> > may print false. Correct? If so can you explain the > >> circumstances? > >> > > >> > Douglas > >> > > >> > > >> > At 01:20 PM 9/6/2012, Roger Riggs wrote: > >> > > >> > In the implementation of multi-unit periods it comes to light > >> that in some > >> > cases between(start, end) is not equal to between(end, > >> start).negated(). > >> > > >> > A developer might reasonably expect that the number of months > and > >> days > >> > between two dates is the same (except for the sign) of two > dates. > >> > > >> > This seems to be a bug. > >> > If it is a feature, it will need to be explained and may still > be > >> a cause of > >> > bugs. > >> > -- > >> > Thanks, Roger > >> > > >> > Oracle Java Platform Group > >> > > >> > Green Oracle <http://www.oracle.com/commitment> Oracle is > >> committed to > >> > developing practices and products that help protect the > >> environment > >> > > >> > > >> > In the implementation of multi-unit periods it comes to light > >> that in some > >> > cases between(start, end) is not equal to between(end, > >> start).negated(). > >> > > >> > A developer might reasonably expect that the number of months > and > >> days > >> > between two dates is the same (except for the sign) of two > dates. > >> > > >> > This seems to be a bug. > >> > If it is a feature, it will need to be explained and may still > be > >> a cause of > >> > bugs. > >> > -- > >> > Thanks, Roger > >> > > >> > Oracle Java Platform Group > >> > > >> > <http://www.oracle.com/commitment> > >> > Green > >> > Oracle is committed to developing practices and products that > >> help protect > >> > the environment > >> > > >> > ------------------------------------------------------------------------------ > >> > Live Security Virtual Conference > >> > Exclusive live event will cover all the ways today's security > and > >> > threat landscape has changed and how IT managers can respond. > >> Discussions > >> > will include endpoint security, mobile security and the latest > in > >> malware > >> > threats. > >> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > >> > > >> > _______________________________________________ > >> > threeten-develop mailing list > >> > thr...@li... > >> > https://lists.sourceforge.net/lists/listinfo/threeten-develop > >> > > >> > > >> > ------------------------------------------------------------------------------ > >> > Live Security Virtual Conference > >> > Exclusive live event will cover all the ways today's security > and > >> > threat landscape has changed and how IT managers can respond. > >> Discussions > >> > will include endpoint security, mobile security and the latest > in > >> malware > >> > threats. > >> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > >> > > >> > _______________________________________________ > >> > threeten-develop mailing list > >> > thr...@li... > >> > https://lists.sourceforge.net/lists/listinfo/threeten-develop > >> > > >> > > >> > > >> > > >> > ------------------------------------------------------------------------------ > >> > Live Security Virtual Conference > >> > Exclusive live event will cover all the ways today's security > and > >> > threat landscape has changed and how IT managers can respond. > >> Discussions > >> > will include endpoint security, mobile security and the latest > in > >> malware > >> > threats. > >> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > >> > _______________________________________________ > >> > threeten-develop mailing list > >> > thr...@li... > >> > https://lists.sourceforge.net/lists/listinfo/threeten-develop > >> > > >> > >>------------------------------------------------------------------ > ------------ > >>Live Security Virtual Conference > >>Exclusive live event will cover all the ways today's security and > >>threat landscape has changed and how IT managers can respond. > >>Discussions > >>will include endpoint security, mobile security and the latest in > >>malware > >>threats. > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > >>_______________________________________________ > >>threeten-develop mailing list > >>thr...@li... > >>https://lists.sourceforge.net/lists/listinfo/threeten-develop > > > > > > > ------------------------------------------------------------------------------ > > Live Security Virtual Conference > > Exclusive live event will cover all the ways today's security and > > threat landscape has changed and how IT managers can respond. > Discussions > > will include endpoint security, mobile security and the latest in > malware > > threats. > http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > > _______________________________________________ > > threeten-develop mailing list > > thr...@li... > > https://lists.sourceforge.net/lists/listinfo/threeten-develop > >------------------------------------------------------------------------------ >Live Security Virtual Conference >Exclusive live event will cover all the ways today's security and >threat landscape has changed and how IT managers can respond. >Discussions >will include endpoint security, mobile security and the latest in >malware >threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >_______________________________________________ >threeten-develop mailing list >thr...@li... >https://lists.sourceforge.net/lists/listinfo/threeten-develop |