Week Interval on Date Histogram Facet
This commit is contained in:
parent
3000dc78fa
commit
d3076945ac
|
@ -61,6 +61,8 @@ public class DateHistogramFacetProcessor extends AbstractComponent implements Fa
|
||||||
.put("1y", new DateFieldParser.YearOfCentury())
|
.put("1y", new DateFieldParser.YearOfCentury())
|
||||||
.put("month", new DateFieldParser.MonthOfYear())
|
.put("month", new DateFieldParser.MonthOfYear())
|
||||||
.put("1m", new DateFieldParser.MonthOfYear())
|
.put("1m", new DateFieldParser.MonthOfYear())
|
||||||
|
.put("week", new DateFieldParser.WeekOfWeekyear())
|
||||||
|
.put("1w", new DateFieldParser.WeekOfWeekyear())
|
||||||
.put("day", new DateFieldParser.DayOfMonth())
|
.put("day", new DateFieldParser.DayOfMonth())
|
||||||
.put("1d", new DateFieldParser.DayOfMonth())
|
.put("1d", new DateFieldParser.DayOfMonth())
|
||||||
.put("hour", new DateFieldParser.HourOfDay())
|
.put("hour", new DateFieldParser.HourOfDay())
|
||||||
|
@ -209,6 +211,12 @@ public class DateHistogramFacetProcessor extends AbstractComponent implements Fa
|
||||||
|
|
||||||
DateTimeField parse(Chronology chronology);
|
DateTimeField parse(Chronology chronology);
|
||||||
|
|
||||||
|
static class WeekOfWeekyear implements DateFieldParser {
|
||||||
|
@Override public DateTimeField parse(Chronology chronology) {
|
||||||
|
return chronology.weekOfWeekyear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class YearOfCentury implements DateFieldParser {
|
static class YearOfCentury implements DateFieldParser {
|
||||||
@Override public DateTimeField parse(Chronology chronology) {
|
@Override public DateTimeField parse(Chronology chronology) {
|
||||||
return chronology.yearOfCentury();
|
return chronology.yearOfCentury();
|
||||||
|
|
|
@ -153,6 +153,12 @@ public class SimpleJodaTests {
|
||||||
time.setMillis(utcTimeInMillis("2009-02-02T23:01:01"));
|
time.setMillis(utcTimeInMillis("2009-02-02T23:01:01"));
|
||||||
assertThat(time.toString(), equalTo("2009-02-02T00:00:00.000Z"));
|
assertThat(time.toString(), equalTo("2009-02-02T00:00:00.000Z"));
|
||||||
assertThat(time.getMillis(), equalTo(utcTimeInMillis("2009-02-02T00:00:00.000Z")));
|
assertThat(time.getMillis(), equalTo(utcTimeInMillis("2009-02-02T00:00:00.000Z")));
|
||||||
|
|
||||||
|
time = new MutableDateTime(DateTimeZone.UTC);
|
||||||
|
time.setRounding(time.getChronology().weekOfWeekyear(), MutableDateTime.ROUND_FLOOR);
|
||||||
|
time.setMillis(utcTimeInMillis("2011-05-05T01:01:01"));
|
||||||
|
assertThat(time.toString(), equalTo("2011-05-02T00:00:00.000Z"));
|
||||||
|
assertThat(time.getMillis(), equalTo(utcTimeInMillis("2011-05-02T00:00:00.000Z")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testRoundingWithTimeZone() {
|
@Test public void testRoundingWithTimeZone() {
|
||||||
|
|
Loading…
Reference in New Issue