Permalink
Browse files

Remove week-of-month and week-of-year

These will be handled separately in WeekDefinition
See #67
  • Loading branch information...
1 parent 84024a8 commit 280f25a00d96df7943b89265ece46e593b823926 @jodastephen jodastephen committed Dec 4, 2012
View
14 src/main/java/javax/time/LocalDate.java
@@ -426,14 +426,6 @@ private LocalDate(int year, int month, int dayOfMonth) {
//-----------------------------------------------------------------------
@Override
- public boolean isSupported(DateTimeField field) {
- if (field instanceof ChronoField) {
- return ((ChronoField) field).isDateField();
- }
- return field != null && field.doIsSupported(this);
- }
-
- @Override
public DateTimeValueRange range(DateTimeField field) {
if (field instanceof ChronoField) {
ChronoField f = (ChronoField) field;
@@ -442,8 +434,6 @@ public DateTimeValueRange range(DateTimeField field) {
case DAY_OF_MONTH: return DateTimeValueRange.of(1, lengthOfMonth());
case DAY_OF_YEAR: return DateTimeValueRange.of(1, lengthOfYear());
case ALIGNED_WEEK_OF_MONTH: return DateTimeValueRange.of(1, getMonth() == Month.FEBRUARY && isLeapYear() == false ? 4 : 5);
- case WEEK_OF_MONTH: throw new UnsupportedOperationException("TODO");
- case WEEK_OF_YEAR: throw new UnsupportedOperationException("TODO");
case YEAR_OF_ERA:
return (getYear() <= 0 ? DateTimeValueRange.of(1, MAX_YEAR + 1) : DateTimeValueRange.of(1, MAX_YEAR));
}
@@ -485,9 +475,7 @@ private int get0(DateTimeField field) {
case DAY_OF_YEAR: return getDayOfYear();
case EPOCH_DAY: throw new DateTimeException("Field too large for an int: " + field);
case ALIGNED_WEEK_OF_MONTH: return ((day - 1) / 7) + 1;
- case WEEK_OF_MONTH: throw new UnsupportedOperationException("TODO");
case ALIGNED_WEEK_OF_YEAR: return ((getDayOfYear() - 1) / 7) + 1;
- case WEEK_OF_YEAR: throw new UnsupportedOperationException("TODO");
case MONTH_OF_YEAR: return month;
case EPOCH_MONTH: throw new DateTimeException("Field too large for an int: " + field);
case YEAR_OF_ERA: return (year >= 1 ? year : 1 - year);
@@ -746,9 +734,7 @@ public LocalDate with(DateTimeField field, long newValue) {
case DAY_OF_YEAR: return withDayOfYear((int) newValue);
case EPOCH_DAY: return LocalDate.ofEpochDay(newValue);
case ALIGNED_WEEK_OF_MONTH: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_MONTH));
- case WEEK_OF_MONTH: throw new UnsupportedOperationException("TODO");
case ALIGNED_WEEK_OF_YEAR: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_YEAR));
- case WEEK_OF_YEAR: throw new UnsupportedOperationException("TODO");
case MONTH_OF_YEAR: return withMonth((int) newValue);
case EPOCH_MONTH: return plusMonths(newValue - getLong(EPOCH_MONTH));
case YEAR_OF_ERA: return withYear((int) (year >= 1 ? newValue : 1 - newValue));
View
46 src/main/java/javax/time/calendrical/ChronoField.java
@@ -324,29 +324,6 @@
*/
ALIGNED_WEEK_OF_MONTH("AlignedWeekOfMonth", WEEKS, MONTHS, DateTimeValueRange.of(1, 4, 5)),
/**
- * The week within a month.
- * <p>
- * This represents concept of the count of weeks within the month where weeks
- * start on a fixed day-of-week, such as Monday.
- * This field is typically used with {@link #DAY_OF_WEEK}.
- * <p>
- * In the default ISO calendar system, the week starts on Monday and there must be at
- * least 4 days in the first week.
- * Week one is the week starting on a Monday where there are at least 4 days in the month.
- * Thus, week one may start up to three days before the start of the month.
- * If the first week starts after the start of the month then the period before is week zero.
- * <p>
- * For example:<br />
- * - if the 1st day of the month is a Monday, week one starts on the 1st and there is no week zero<br />
- * - if the 2nd day of the month is a Monday, week one starts on the 2nd and the 1st is in week zero<br />
- * - 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 />
- * - 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 />
- * <p>
- * Non-ISO calendar systems should implement this field in the same way, taking
- * into account any differences in week or month length.
- */
- WEEK_OF_MONTH("WeekOfMonth", WEEKS, MONTHS, DateTimeValueRange.of(0, 1, 4, 5)),
- /**
* The aligned week within a year.
* <p>
* This represents concept of the count of weeks within the period of a year
@@ -363,29 +340,6 @@
*/
ALIGNED_WEEK_OF_YEAR("AlignedWeekOfYear", WEEKS, YEARS, DateTimeValueRange.of(1, 53)),
/**
- * The week within a year.
- * <p>
- * This represents concept of the count of weeks within the year where weeks
- * start on a fixed day-of-week, such as Monday.
- * This field is typically used with {@link #DAY_OF_WEEK}.
- * <p>
- * In the default ISO calendar system, the week starts on Monday and there must be at
- * least 4 days in the first week.
- * Week one is the week starting on a Monday where there are at least 4 days in the year.
- * Thus, week one may start up to three days before the start of the year.
- * If the first week starts after the start of the year then the period before is week zero.
- * <p>
- * For example:<br />
- * - if the 1st day of the year is a Monday, week one starts on the 1st and there is no week zero<br />
- * - if the 2nd day of the year is a Monday, week one starts on the 2nd and the 1st is in week zero<br />
- * - 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 />
- * - 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 />
- * <p>
- * Non-ISO calendar systems should implement this field in the same way, taking
- * into account any differences in week or year length.
- */
- WEEK_OF_YEAR("WeekOfYear", WEEKS, YEARS, DateTimeValueRange.of(0, 1, 52, 53)),
- /**
* The month-of-year, such as March.
* <p>
* This represents the concept of the month within the year.
View
15 src/main/java/javax/time/chrono/global/ChronoDateImpl.java
@@ -31,19 +31,14 @@
*/
package javax.time.chrono.global;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
-
import java.io.Serializable;
import javax.time.DateTimeException;
import javax.time.LocalDate;
import javax.time.LocalTime;
-import javax.time.calendrical.ChronoField;
import javax.time.calendrical.ChronoUnit;
import javax.time.calendrical.DateTime;
import javax.time.calendrical.DateTime.WithAdjuster;
-import javax.time.calendrical.DateTimeField;
import javax.time.calendrical.PeriodUnit;
import javax.time.chrono.Chrono;
import javax.time.chrono.ChronoLocalDate;
@@ -134,16 +129,6 @@
//-----------------------------------------------------------------------
@Override
- public boolean isSupported(DateTimeField field) {
- if (field instanceof ChronoField) {
- return ((ChronoField) field).isDateField() &&
- field != WEEK_OF_MONTH && field != WEEK_OF_YEAR;
- }
- return field != null && field.doIsSupported(this);
- }
-
- //-----------------------------------------------------------------------
- @Override
public ChronoDateImpl<C> plus(long amountToAdd, PeriodUnit unit) {
if (unit instanceof ChronoUnit) {
ChronoUnit f = (ChronoUnit) unit;
View
4 src/main/java/javax/time/chrono/global/JapaneseChrono.java
@@ -315,10 +315,6 @@ public DateTimeValueRange range(ChronoField field) {
case MONTH_OF_YEAR:
return DateTimeValueRange.of(jcal.getMinimum(Calendar.MONTH) + 1, jcal.getGreatestMinimum(Calendar.MONTH) + 1,
jcal.getLeastMaximum(Calendar.MONTH) + 1, jcal.getMaximum(Calendar.MONTH) + 1);
- case WEEK_OF_YEAR:
- // TODO: revisit this when the week definition gets clear
- fieldIndex = Calendar.WEEK_OF_YEAR;
- break;
case DAY_OF_YEAR:
fieldIndex = Calendar.DAY_OF_YEAR;
break;
View
3 src/main/java/javax/time/chrono/global/JapaneseDate.java
@@ -197,9 +197,6 @@ public long getLong(DateTimeField field) {
LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(isoDate);
return JapaneseChrono.JCAL.getDayOfYear(jdate);
}
- case WEEK_OF_YEAR:
- // TODO: need to resolve week of year issues with Japanese calendar.
- break;
}
// TODO: review other fields
return isoDate.getLong(field);
View
10 src/main/java/javax/time/jdk8/DefaultInterfaceChronoLocalDate.java
@@ -41,7 +41,9 @@
import java.util.Objects;
import javax.time.LocalTime;
+import javax.time.calendrical.ChronoField;
import javax.time.calendrical.DateTime;
+import javax.time.calendrical.DateTimeField;
import javax.time.calendrical.PeriodUnit;
import javax.time.chrono.Chrono;
import javax.time.chrono.ChronoLocalDate;
@@ -74,6 +76,14 @@ public int lengthOfYear() {
return (isLeapYear() ? 366 : 365);
}
+ @Override
+ public boolean isSupported(DateTimeField field) {
+ if (field instanceof ChronoField) {
+ return ((ChronoField) field).isDateField();
+ }
+ return field != null && field.doIsSupported(this);
+ }
+
//-------------------------------------------------------------------------
@Override
public ChronoLocalDate<C> with(WithAdjuster adjuster) {
View
4 src/tck/java/javax/time/TCKLocalDate.java
@@ -42,8 +42,6 @@
import static javax.time.calendrical.ChronoField.EPOCH_MONTH;
import static javax.time.calendrical.ChronoField.ERA;
import static javax.time.calendrical.ChronoField.MONTH_OF_YEAR;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
import static javax.time.calendrical.ChronoField.YEAR;
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
import static org.testng.Assert.assertEquals;
@@ -131,9 +129,7 @@ public void setUp() {
DAY_OF_YEAR,
EPOCH_DAY,
ALIGNED_WEEK_OF_MONTH,
- WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
- WEEK_OF_YEAR,
MONTH_OF_YEAR,
EPOCH_MONTH,
YEAR_OF_ERA,
View
4 src/tck/java/javax/time/TCKLocalDateTime.java
@@ -57,8 +57,6 @@
import static javax.time.calendrical.ChronoField.NANO_OF_SECOND;
import static javax.time.calendrical.ChronoField.SECOND_OF_DAY;
import static javax.time.calendrical.ChronoField.SECOND_OF_MINUTE;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
import static javax.time.calendrical.ChronoField.YEAR;
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
import static javax.time.calendrical.ChronoUnit.NANOS;
@@ -157,9 +155,7 @@ public void setUp() {
DAY_OF_YEAR,
EPOCH_DAY,
ALIGNED_WEEK_OF_MONTH,
- WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
- WEEK_OF_YEAR,
MONTH_OF_YEAR,
EPOCH_MONTH,
YEAR_OF_ERA,
View
6 src/tck/java/javax/time/TCKOffsetDate.java
@@ -44,8 +44,6 @@
import static javax.time.calendrical.ChronoField.ERA;
import static javax.time.calendrical.ChronoField.MONTH_OF_YEAR;
import static javax.time.calendrical.ChronoField.OFFSET_SECONDS;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
import static javax.time.calendrical.ChronoField.YEAR;
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
import static org.testng.Assert.assertEquals;
@@ -64,8 +62,8 @@
import javax.time.calendrical.DateTime.MinusAdjuster;
import javax.time.calendrical.DateTime.PlusAdjuster;
import javax.time.calendrical.DateTime.WithAdjuster;
-import javax.time.calendrical.DateTimeAccessor.Query;
import javax.time.calendrical.DateTimeAccessor;
+import javax.time.calendrical.DateTimeAccessor.Query;
import javax.time.calendrical.DateTimeField;
import javax.time.calendrical.JulianDayField;
import javax.time.calendrical.MockFieldNoValue;
@@ -110,9 +108,7 @@ public void setUp() {
DAY_OF_YEAR,
EPOCH_DAY,
ALIGNED_WEEK_OF_MONTH,
- WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
- WEEK_OF_YEAR,
MONTH_OF_YEAR,
EPOCH_MONTH,
YEAR_OF_ERA,
View
6 src/tck/java/javax/time/TCKOffsetDateTime.java
@@ -60,8 +60,6 @@
import static javax.time.calendrical.ChronoField.OFFSET_SECONDS;
import static javax.time.calendrical.ChronoField.SECOND_OF_DAY;
import static javax.time.calendrical.ChronoField.SECOND_OF_MINUTE;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
import static javax.time.calendrical.ChronoField.YEAR;
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
import static javax.time.calendrical.ChronoUnit.NANOS;
@@ -79,8 +77,8 @@
import javax.time.calendrical.ChronoUnit;
import javax.time.calendrical.DateTime;
import javax.time.calendrical.DateTime.WithAdjuster;
-import javax.time.calendrical.DateTimeAccessor.Query;
import javax.time.calendrical.DateTimeAccessor;
+import javax.time.calendrical.DateTimeAccessor.Query;
import javax.time.calendrical.DateTimeField;
import javax.time.calendrical.JulianDayField;
import javax.time.calendrical.MockFieldNoValue;
@@ -144,9 +142,7 @@ public void setUp() {
DAY_OF_YEAR,
EPOCH_DAY,
ALIGNED_WEEK_OF_MONTH,
- WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
- WEEK_OF_YEAR,
MONTH_OF_YEAR,
EPOCH_MONTH,
YEAR_OF_ERA,
View
4 src/tck/java/javax/time/TCKZonedDateTime.java
@@ -60,8 +60,6 @@
import static javax.time.calendrical.ChronoField.OFFSET_SECONDS;
import static javax.time.calendrical.ChronoField.SECOND_OF_DAY;
import static javax.time.calendrical.ChronoField.SECOND_OF_MINUTE;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
import static javax.time.calendrical.ChronoField.YEAR;
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
import static javax.time.calendrical.ChronoUnit.DAYS;
@@ -162,9 +160,7 @@ public void setUp() {
DAY_OF_YEAR,
EPOCH_DAY,
ALIGNED_WEEK_OF_MONTH,
- WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
- WEEK_OF_YEAR,
MONTH_OF_YEAR,
EPOCH_MONTH,
YEAR_OF_ERA,
View
4 src/test/java/javax/time/TestLocalDate.java
@@ -42,8 +42,6 @@
import static javax.time.calendrical.ChronoField.EPOCH_MONTH;
import static javax.time.calendrical.ChronoField.ERA;
import static javax.time.calendrical.ChronoField.MONTH_OF_YEAR;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
import static javax.time.calendrical.ChronoField.YEAR;
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
import static org.testng.Assert.assertEquals;
@@ -96,9 +94,7 @@ public void setUp() {
DAY_OF_YEAR,
EPOCH_DAY,
ALIGNED_WEEK_OF_MONTH,
- WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
- WEEK_OF_YEAR,
MONTH_OF_YEAR,
EPOCH_MONTH,
YEAR_OF_ERA,
View
4 src/test/java/javax/time/TestLocalDateTime.java
@@ -57,8 +57,6 @@
import static javax.time.calendrical.ChronoField.NANO_OF_SECOND;
import static javax.time.calendrical.ChronoField.SECOND_OF_DAY;
import static javax.time.calendrical.ChronoField.SECOND_OF_MINUTE;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
import static javax.time.calendrical.ChronoField.YEAR;
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
import static org.testng.Assert.assertEquals;
@@ -120,9 +118,7 @@
DAY_OF_YEAR,
EPOCH_DAY,
ALIGNED_WEEK_OF_MONTH,
- WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
- WEEK_OF_YEAR,
MONTH_OF_YEAR,
EPOCH_MONTH,
YEAR_OF_ERA,
View
4 src/test/java/javax/time/TestOffsetDateTime.java
@@ -59,8 +59,6 @@
import static javax.time.calendrical.ChronoField.OFFSET_SECONDS;
import static javax.time.calendrical.ChronoField.SECOND_OF_DAY;
import static javax.time.calendrical.ChronoField.SECOND_OF_MINUTE;
-import static javax.time.calendrical.ChronoField.WEEK_OF_MONTH;
-import static javax.time.calendrical.ChronoField.WEEK_OF_YEAR;
import static javax.time.calendrical.ChronoField.YEAR;
import static javax.time.calendrical.ChronoField.YEAR_OF_ERA;
import static org.testng.Assert.assertSame;
@@ -128,9 +126,7 @@ public void setUp() {
DAY_OF_YEAR,
EPOCH_DAY,
ALIGNED_WEEK_OF_MONTH,
- WEEK_OF_MONTH,
ALIGNED_WEEK_OF_YEAR,
- WEEK_OF_YEAR,
MONTH_OF_YEAR,
EPOCH_MONTH,
YEAR_OF_ERA,

0 comments on commit 280f25a

Please sign in to comment.