Skip to content
This repository was archived by the owner on Mar 20, 2018. It is now read-only.

Commit 280f25a

Browse files
committed
Remove week-of-month and week-of-year
These will be handled separately in WeekDefinition See #67
1 parent 84024a8 commit 280f25a

14 files changed

+12
-116
lines changed

src/main/java/javax/time/LocalDate.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,6 @@ private LocalDate(int year, int month, int dayOfMonth) {
425425
}
426426

427427
//-----------------------------------------------------------------------
428-
@Override
429-
public boolean isSupported(DateTimeField field) {
430-
if (field instanceof ChronoField) {
431-
return ((ChronoField) field).isDateField();
432-
}
433-
return field != null && field.doIsSupported(this);
434-
}
435-
436428
@Override
437429
public DateTimeValueRange range(DateTimeField field) {
438430
if (field instanceof ChronoField) {
@@ -442,8 +434,6 @@ public DateTimeValueRange range(DateTimeField field) {
442434
case DAY_OF_MONTH: return DateTimeValueRange.of(1, lengthOfMonth());
443435
case DAY_OF_YEAR: return DateTimeValueRange.of(1, lengthOfYear());
444436
case ALIGNED_WEEK_OF_MONTH: return DateTimeValueRange.of(1, getMonth() == Month.FEBRUARY && isLeapYear() == false ? 4 : 5);
445-
case WEEK_OF_MONTH: throw new UnsupportedOperationException("TODO");
446-
case WEEK_OF_YEAR: throw new UnsupportedOperationException("TODO");
447437
case YEAR_OF_ERA:
448438
return (getYear() <= 0 ? DateTimeValueRange.of(1, MAX_YEAR + 1) : DateTimeValueRange.of(1, MAX_YEAR));
449439
}
@@ -485,9 +475,7 @@ private int get0(DateTimeField field) {
485475
case DAY_OF_YEAR: return getDayOfYear();
486476
case EPOCH_DAY: throw new DateTimeException("Field too large for an int: " + field);
487477
case ALIGNED_WEEK_OF_MONTH: return ((day - 1) / 7) + 1;
488-
case WEEK_OF_MONTH: throw new UnsupportedOperationException("TODO");
489478
case ALIGNED_WEEK_OF_YEAR: return ((getDayOfYear() - 1) / 7) + 1;
490-
case WEEK_OF_YEAR: throw new UnsupportedOperationException("TODO");
491479
case MONTH_OF_YEAR: return month;
492480
case EPOCH_MONTH: throw new DateTimeException("Field too large for an int: " + field);
493481
case YEAR_OF_ERA: return (year >= 1 ? year : 1 - year);
@@ -746,9 +734,7 @@ public LocalDate with(DateTimeField field, long newValue) {
746734
case DAY_OF_YEAR: return withDayOfYear((int) newValue);
747735
case EPOCH_DAY: return LocalDate.ofEpochDay(newValue);
748736
case ALIGNED_WEEK_OF_MONTH: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_MONTH));
749-
case WEEK_OF_MONTH: throw new UnsupportedOperationException("TODO");
750737
case ALIGNED_WEEK_OF_YEAR: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_YEAR));
751-
case WEEK_OF_YEAR: throw new UnsupportedOperationException("TODO");
752738
case MONTH_OF_YEAR: return withMonth((int) newValue);
753739
case EPOCH_MONTH: return plusMonths(newValue - getLong(EPOCH_MONTH));
754740
case YEAR_OF_ERA: return withYear((int) (year >= 1 ? newValue : 1 - newValue));

src/main/java/javax/time/calendrical/ChronoField.java

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -323,29 +323,6 @@ public enum ChronoField implements DateTimeField {
323323
* field in the same way, but using the alternate week length.
324324
*/
325325
ALIGNED_WEEK_OF_MONTH("AlignedWeekOfMonth", WEEKS, MONTHS, DateTimeValueRange.of(1, 4, 5)),
326-
/**
327-
* The week within a month.
328-
* <p>
329-
* This represents concept of the count of weeks within the month where weeks
330-
* start on a fixed day-of-week, such as Monday.
331-
* This field is typically used with {@link #DAY_OF_WEEK}.
332-
* <p>
333-
* In the default ISO calendar system, the week starts on Monday and there must be at
334-
* least 4 days in the first week.
335-
* Week one is the week starting on a Monday where there are at least 4 days in the month.
336-
* Thus, week one may start up to three days before the start of the month.
337-
* If the first week starts after the start of the month then the period before is week zero.
338-
* <p>
339-
* For example:<br />
340-
* - if the 1st day of the month is a Monday, week one starts on the 1st and there is no week zero<br />
341-
* - if the 2nd day of the month is a Monday, week one starts on the 2nd and the 1st is in week zero<br />
342-
* - if the 4th day of the month is a Monday, week one starts on the 4th and the 1st to 3rd is in week zero<br />
343-
* - if the 5th day of the month is a Monday, week two starts on the 5th and the 1st to 4th is in week one<br />
344-
* <p>
345-
* Non-ISO calendar systems should implement this field in the same way, taking
346-
* into account any differences in week or month length.
347-
*/
348-
WEEK_OF_MONTH("WeekOfMonth", WEEKS, MONTHS, DateTimeValueRange.of(0, 1, 4, 5)),
349326
/**
350327
* The aligned week within a year.
351328
* <p>
@@ -362,29 +339,6 @@ public enum ChronoField implements DateTimeField {
362339
* field in the same way, but using the alternate week length.
363340
*/
364341
ALIGNED_WEEK_OF_YEAR("AlignedWeekOfYear", WEEKS, YEARS, DateTimeValueRange.of(1, 53)),
365-
/**
366-
* The week within a year.
367-
* <p>
368-
* This represents concept of the count of weeks within the year where weeks
369-
* start on a fixed day-of-week, such as Monday.
370-
* This field is typically used with {@link #DAY_OF_WEEK}.
371-
* <p>
372-
* In the default ISO calendar system, the week starts on Monday and there must be at
373-
* least 4 days in the first week.
374-
* Week one is the week starting on a Monday where there are at least 4 days in the year.
375-
* Thus, week one may start up to three days before the start of the year.
376-
* If the first week starts after the start of the year then the period before is week zero.
377-
* <p>
378-
* For example:<br />
379-
* - if the 1st day of the year is a Monday, week one starts on the 1st and there is no week zero<br />
380-
* - if the 2nd day of the year is a Monday, week one starts on the 2nd and the 1st is in week zero<br />
381-
* - if the 4th day of the year is a Monday, week one starts on the 4th and the 1st to 3rd is in week zero<br />
382-
* - if the 5th day of the year is a Monday, week two starts on the 5th and the 1st to 4th is in week one<br />
383-
* <p>
384-
* Non-ISO calendar systems should implement this field in the same way, taking
385-
* into account any differences in week or year length.
386-
*/
387-
WEEK_OF_YEAR("WeekOfYear", WEEKS, YEARS, DateTimeValueRange.of(0, 1, 52, 53)),
388342
/**
389343
* The month-of-year, such as March.
390344
* <p>

src/main/java/javax/time/chrono/global/ChronoDateImpl.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,14 @@
3131
*/
3232
package javax.time.chrono.global;
3333

34-
import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
35-
import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
36-
3734
import java.io.Serializable;
3835

3936
import javax.time.DateTimeException;
4037
import javax.time.LocalDate;
4138
import javax.time.LocalTime;
42-
import javax.time.calendrical.ChronoField;
4339
import javax.time.calendrical.ChronoUnit;
4440
import javax.time.calendrical.DateTime;
4541
import javax.time.calendrical.DateTime.WithAdjuster;
46-
import javax.time.calendrical.DateTimeField;
4742
import javax.time.calendrical.PeriodUnit;
4843
import javax.time.chrono.Chrono;
4944
import javax.time.chrono.ChronoLocalDate;
@@ -132,16 +127,6 @@ abstract class ChronoDateImpl<C extends Chrono<C>>
132127
ChronoDateImpl() {
133128
}
134129

135-
//-----------------------------------------------------------------------
136-
@Override
137-
public boolean isSupported(DateTimeField field) {
138-
if (field instanceof ChronoField) {
139-
return ((ChronoField) field).isDateField() &&
140-
field != WEEK_OF_MONTH && field != WEEK_OF_YEAR;
141-
}
142-
return field != null && field.doIsSupported(this);
143-
}
144-
145130
//-----------------------------------------------------------------------
146131
@Override
147132
public ChronoDateImpl<C> plus(long amountToAdd, PeriodUnit unit) {

src/main/java/javax/time/chrono/global/JapaneseChrono.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,6 @@ public DateTimeValueRange range(ChronoField field) {
315315
case MONTH_OF_YEAR:
316316
return DateTimeValueRange.of(jcal.getMinimum(Calendar.MONTH) + 1, jcal.getGreatestMinimum(Calendar.MONTH) + 1,
317317
jcal.getLeastMaximum(Calendar.MONTH) + 1, jcal.getMaximum(Calendar.MONTH) + 1);
318-
case WEEK_OF_YEAR:
319-
// TODO: revisit this when the week definition gets clear
320-
fieldIndex = Calendar.WEEK_OF_YEAR;
321-
break;
322318
case DAY_OF_YEAR:
323319
fieldIndex = Calendar.DAY_OF_YEAR;
324320
break;

src/main/java/javax/time/chrono/global/JapaneseDate.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ public long getLong(DateTimeField field) {
197197
LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(isoDate);
198198
return JapaneseChrono.JCAL.getDayOfYear(jdate);
199199
}
200-
case WEEK_OF_YEAR:
201-
// TODO: need to resolve week of year issues with Japanese calendar.
202-
break;
203200
}
204201
// TODO: review other fields
205202
return isoDate.getLong(field);

src/main/java/javax/time/jdk8/DefaultInterfaceChronoLocalDate.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
import java.util.Objects;
4242

4343
import javax.time.LocalTime;
44+
import javax.time.calendrical.ChronoField;
4445
import javax.time.calendrical.DateTime;
46+
import javax.time.calendrical.DateTimeField;
4547
import javax.time.calendrical.PeriodUnit;
4648
import javax.time.chrono.Chrono;
4749
import javax.time.chrono.ChronoLocalDate;
@@ -74,6 +76,14 @@ public int lengthOfYear() {
7476
return (isLeapYear() ? 366 : 365);
7577
}
7678

79+
@Override
80+
public boolean isSupported(DateTimeField field) {
81+
if (field instanceof ChronoField) {
82+
return ((ChronoField) field).isDateField();
83+
}
84+
return field != null && field.doIsSupported(this);
85+
}
86+
7787
//-------------------------------------------------------------------------
7888
@Override
7989
public ChronoLocalDate<C> with(WithAdjuster adjuster) {

src/tck/java/javax/time/TCKLocalDate.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
import static javax.time.calendrical.ChronoField.EPOCH_MONTH;
4343
import static javax.time.calendrical.ChronoField.ERA;
4444
import static javax.time.calendrical.ChronoField.MONTH_OF_YEAR;
45-
import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
46-
import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
4745
import static javax.time.calendrical.ChronoField.YEAR;
4846
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
4947
import static org.testng.Assert.assertEquals;
@@ -131,9 +129,7 @@ protected List<DateTimeField> validFields() {
131129
DAY_OF_YEAR,
132130
EPOCH_DAY,
133131
ALIGNED_WEEK_OF_MONTH,
134-
WEEK_OF_MONTH,
135132
ALIGNED_WEEK_OF_YEAR,
136-
WEEK_OF_YEAR,
137133
MONTH_OF_YEAR,
138134
EPOCH_MONTH,
139135
YEAR_OF_ERA,

src/tck/java/javax/time/TCKLocalDateTime.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
import static javax.time.calendrical.ChronoField.NANO_OF_SECOND;
5858
import static javax.time.calendrical.ChronoField.SECOND_OF_DAY;
5959
import static javax.time.calendrical.ChronoField.SECOND_OF_MINUTE;
60-
import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
61-
import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
6260
import static javax.time.calendrical.ChronoField.YEAR;
6361
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
6462
import static javax.time.calendrical.ChronoUnit.NANOS;
@@ -157,9 +155,7 @@ protected List<DateTimeField> validFields() {
157155
DAY_OF_YEAR,
158156
EPOCH_DAY,
159157
ALIGNED_WEEK_OF_MONTH,
160-
WEEK_OF_MONTH,
161158
ALIGNED_WEEK_OF_YEAR,
162-
WEEK_OF_YEAR,
163159
MONTH_OF_YEAR,
164160
EPOCH_MONTH,
165161
YEAR_OF_ERA,

src/tck/java/javax/time/TCKOffsetDate.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import static javax.time.calendrical.ChronoField.ERA;
4545
import static javax.time.calendrical.ChronoField.MONTH_OF_YEAR;
4646
import static javax.time.calendrical.ChronoField.OFFSET_SECONDS;
47-
import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
48-
import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
4947
import static javax.time.calendrical.ChronoField.YEAR;
5048
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
5149
import static org.testng.Assert.assertEquals;
@@ -64,8 +62,8 @@
6462
import javax.time.calendrical.DateTime.MinusAdjuster;
6563
import javax.time.calendrical.DateTime.PlusAdjuster;
6664
import javax.time.calendrical.DateTime.WithAdjuster;
67-
import javax.time.calendrical.DateTimeAccessor.Query;
6865
import javax.time.calendrical.DateTimeAccessor;
66+
import javax.time.calendrical.DateTimeAccessor.Query;
6967
import javax.time.calendrical.DateTimeField;
7068
import javax.time.calendrical.JulianDayField;
7169
import javax.time.calendrical.MockFieldNoValue;
@@ -110,9 +108,7 @@ protected List<DateTimeField> validFields() {
110108
DAY_OF_YEAR,
111109
EPOCH_DAY,
112110
ALIGNED_WEEK_OF_MONTH,
113-
WEEK_OF_MONTH,
114111
ALIGNED_WEEK_OF_YEAR,
115-
WEEK_OF_YEAR,
116112
MONTH_OF_YEAR,
117113
EPOCH_MONTH,
118114
YEAR_OF_ERA,

src/tck/java/javax/time/TCKOffsetDateTime.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@
6060
import static javax.time.calendrical.ChronoField.OFFSET_SECONDS;
6161
import static javax.time.calendrical.ChronoField.SECOND_OF_DAY;
6262
import static javax.time.calendrical.ChronoField.SECOND_OF_MINUTE;
63-
import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
64-
import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
6563
import static javax.time.calendrical.ChronoField.YEAR;
6664
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
6765
import static javax.time.calendrical.ChronoUnit.NANOS;
@@ -79,8 +77,8 @@
7977
import javax.time.calendrical.ChronoUnit;
8078
import javax.time.calendrical.DateTime;
8179
import javax.time.calendrical.DateTime.WithAdjuster;
82-
import javax.time.calendrical.DateTimeAccessor.Query;
8380
import javax.time.calendrical.DateTimeAccessor;
81+
import javax.time.calendrical.DateTimeAccessor.Query;
8482
import javax.time.calendrical.DateTimeField;
8583
import javax.time.calendrical.JulianDayField;
8684
import javax.time.calendrical.MockFieldNoValue;
@@ -144,9 +142,7 @@ protected List<DateTimeField> validFields() {
144142
DAY_OF_YEAR,
145143
EPOCH_DAY,
146144
ALIGNED_WEEK_OF_MONTH,
147-
WEEK_OF_MONTH,
148145
ALIGNED_WEEK_OF_YEAR,
149-
WEEK_OF_YEAR,
150146
MONTH_OF_YEAR,
151147
EPOCH_MONTH,
152148
YEAR_OF_ERA,

0 commit comments

Comments
 (0)