public Time2D(CalendarDate refDate, Integer time, TimeCoord.Tinv tinv) { this.refDate = refDate.getMillis(); this.time = time; this.tinv = tinv; }
/** * Get ISO formatted string * * @return ISO formatted date */ public String toDateTimeStringISO() { return date.toString(); }
public CalendarDateRange(CalendarDate start, long durationInSecs) { this.start = start; this.end = start.add((int) durationInSecs, CalendarPeriod.Field.Second ); this.startDt = start.getDateTime(); this.endDt = end.getDateTime(); this.cal = start.getCalendar(); }
private CalendarDateRange(CalendarDate start, CalendarDate end) { this.start = start; this.end = end; this.startDt = start.getDateTime(); this.endDt = end.getDateTime(); this.cal = start.getCalendar(); assert this.cal == end.getCalendar(); }
public double makeOffsetFromRefDate( CalendarDate date) { if (isCalendarField) { if (date.equals(baseDate)) return 0.0; return date.getDifference(baseDate, periodField); } else { long msecs = date.getDifferenceInMsecs(baseDate); return msecs / period.getValueInMillisecs(); } }
protected void setEndDate() { String datetime = ds.findAttValueIgnoreCase(null, "time_coverage_end", null); if (datetime != null) { endDate = CalendarDate.parseISOformat(null, datetime).toDate(); } else { endDate = calDateUnits.makeCalendarDate(time[time.length - 1]).toDate(); } }
protected void trackBB(LatLonPoint loc, CalendarDate obsDate) { if (loc != null) { if (llbb == null) { llbb = new LatLonRect(loc, .001, .001); return; } llbb.extend(loc); } // date is handled specially if ((minDate == null) || minDate.isAfter(obsDate)) minDate = obsDate; if ((maxDate == null) || maxDate.isBefore(obsDate)) maxDate = obsDate; }
public Iterable<MCollection> makePartitions(CollectionUpdateType forceCollection) throws IOException { List<MCollection> result = new ArrayList<>(); CollectionListRange curr = null; CalendarDate startDate = null; CalendarDate endDate = null; for (MFile mfile : getFilesSorted()) { CalendarDate cdate = dateExtractor.getCalendarDate(mfile); if (cdate == null) continue; // skip - error should be logged if ((curr == null) || !endDate.isAfter(cdate)) { startDate = cdate.truncate(timePeriod.getField()); // start on a boundary endDate = startDate.add( timePeriod); String name = collectionName + "-"+ cdf.toString(startDate); curr = new CollectionListRange(name, root, startDate, endDate, this.logger); curr.putAuxInfo(FeatureCollectionConfig.AUX_CONFIG, this.config); if (!wasRemoved( curr)) result.add(curr); // skip if in removed list } //System.out.printf("%s%n", mfile); curr.addFile(mfile); } return result; }
CdmrFeatureProto.CalendarDateRange.Builder encodeDateRange(CalendarDateRange dateRange) { CdmrFeatureProto.CalendarDateRange.Builder builder = CdmrFeatureProto.CalendarDateRange.newBuilder(); builder.setStart(dateRange.getStart().getMillis()); builder.setEnd(dateRange.getEnd().getMillis()); Calendar cal = dateRange.getStart().getCalendar(); builder.setCalendar(convertCalendar(cal)); return builder; }
public TestGribCoverageSubsetP(String endpoint, String covName, String rt_val, String time_val, Double time_offset, Double vert_level) { this.endpoint = endpoint; this.covName = covName; this.rt_val = (rt_val == null) ? null : CalendarDate.parseISOformat(null, rt_val); this.time_val = (time_val == null) ? null : CalendarDate.parseISOformat(null, time_val); this.time_offset = time_offset; this.vert_level = vert_level; }
CalendarDate time = CalendarDate.parseISOformat(null, "2015-03-01T15:00:00Z"); params.set(SubsetParams.time, time); params.set(SubsetParams.runtimeAll, true); if (timeAxis.isInterval()) { CalendarDate lower = timeAxis1D.makeDate(timeAxis1D.getCoordEdge1(0)); Assert.assertTrue("time coord lower", !lower.isAfter(time)); // lower <= time CalendarDate upper = timeAxis1D.makeDate(timeAxis1D.getCoordEdge2(0)); Assert.assertTrue("time coord lower", !upper.isBefore(time)); // upper >= time
extract.extract(sdata); CalendarDate date = extract.makeCalendarDate(); if (Math.abs(date.getDifferenceInMsecs(today)) > 1000L * 3600 * 24 * 100) { extract.makeCalendarDate(); long msecs = date.getMillis(); if (this.start > msecs) { this.start = msecs;
/** * Create a date from base and hour offset * @param base base date * @param offset hourss * @return base + offset as a Date */ public static CalendarDate makeOffsetDate(CalendarDate base, double offset) { return base.add(offset, CalendarPeriod.Field.Hour); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; TinvDate tinvDate = (TinvDate) o; if (end != null ? !end.equals(tinvDate.end) : tinvDate.end != null) return false; if (start != null ? !start.equals(tinvDate.start) : tinvDate.start != null) return false; return true; }
/** * Constructor using a java.util.Date * * @param isPresent if true, this represents the "present time" * @param date the given Date */ public DateType(boolean isPresent, java.util.Date date) { this.isPresent = isPresent; this.date = isPresent ? null : CalendarDate.of(date); }
/** * Find the difference between two dates in hours * @param base date1 * @param forecast date2 * @return (forecast minus base) difference in hours */ public static double getOffsetInHours(CalendarDate base, CalendarDate forecast) { long diff = forecast.getDifferenceInMsecs(base); return diff / 1000.0 / 60.0 / 60.0; }
@Test public void checkNCSSDates() throws JDOMException, IOException { String endpoint = TestOnLocalServer.withHttpPath("/ncss/grid/cdmUnitTest/ncss/climatology/PF5_SST_Climatology_Monthly_1985_2001.nc?var=sst&latitude=45&longitude=-20&temporal=all&accept=xml"); byte[] result = TestOnLocalServer.getContent(endpoint, 200, ContentType.xml); String results = new String(result, CDM.utf8Charset); if (show) System.out.printf("checkNCSSDates%n%s%n", results); Reader in = new StringReader( results ); SAXBuilder sb = new SAXBuilder(); Document doc = sb.build(in); XPathExpression<Element> xpath = XPathFactory.instance().compile("/stationFeatureCollection/stationFeature", Filters.element()); List<Element> dataTimeNodes = xpath.evaluate(doc); List<String> timePositionDateTime = new ArrayList<>(); for (Element e : dataTimeNodes) { CalendarDate cd = CalendarDate.parseISOformat(null, e.getAttributeValue("date")); System.out.printf(" extract date= %s%n", cd); timePositionDateTime.add(cd.toString());; } assertEquals(expectedDatesAsDateTime, timePositionDateTime); }