Subversion Repository Public Repository

litesoft

Diff Revisions 859 vs 861 for /trunk/Java/core/Anywhere/src/org/litesoft/core/simpletypes/temporal/AbstractCalendarYMD.java

Diff revisions: vs.
  @@ -21,6 +21,32 @@
21 21 return mDay;
22 22 }
23 23
24 + /**
25 + * Return a T with the Day set to the parameter, this is accomplished by utilizing addDays or minusDays as is appropriate (with their day
26 + * adjusting logic if appropriate).
27 + */
28 + public final T day( int pDay )
29 + {
30 + validate( getYear(), getMonth(), pDay );
31 + return (mDay == pDay) ? us() : (pDay > mDay) ? LLsetDay( pDay, true ) : LLsetDay( pDay, false );
32 + }
33 +
34 + /**
35 + * if after add pDay there are insufficient days in the new month, the date will be set to the 1st of the next month.
36 + */
37 + public final T addDays( int pDays )
38 + {
39 + return (pDays == 0) ? us() : LLsetDay( mDay + pDays, true );
40 + }
41 +
42 + /**
43 + * if after minus pDays there are insufficient days in the new month, the date will be set to the last day of the target month
44 + */
45 + public final T minusDays( int pDays )
46 + {
47 + return (pDays == 0) ? us() : LLsetDay( mDay - pDays, false );
48 + }
49 +
24 50 // vvvvvvvvvvvvvvvvvv Support methods vvvvvvvvvvvvvvvvv
25 51
26 52 protected static final int validate( int pYear, int pMonth, int pDay )
  @@ -57,9 +83,9 @@
57 83 }
58 84
59 85 /**
60 - * @param pNewMonth != current
86 + * @param pNewDay != current
61 87 */
62 - abstract protected T LLsetMonth( int pNewMonth, boolean pAdjustForward );
88 + abstract protected T LLsetDay( int pNewDay, boolean pAdjustForward );
63 89
64 90 protected static class Mutable extends AbstractCalendarYM.Mutable
65 91 {