return new SUTime.GroundedTime(new Instant(refInstant.get().toEpochMilli()));
return new SUTime.GroundedTime(new Instant(refInstant.get().toEpochMilli()));
public SUTime.Temporal apply(String text) { // TODO: TIMEZONE? DateTime dateTime = null; try { dateTime = formatter.parseDateTime(text); } catch(org.joda.time.IllegalFieldValueException e) { logger.warning("WARNING: Invalid temporal \"" + text + "\" (" + e.getMessage() + "). Skipping and continuing..."); return null; } assert(dateTime != null); if (hasDate && hasTime) { return new SUTime.GroundedTime(dateTime); // return new SUTime.IsoDateTime( new SUTime.IsoTime(dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()); // Date d = new SUTime.IsoDate(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth()) ); } else if (hasTime) { // TODO: Millisecs? return new SUTime.IsoTime(dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()); } else if (hasDate) { return new SUTime.IsoDate(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth()); } else { return null; } }
public static final SUTime.Time getCurrentTime() { return new GroundedTime(new DateTime()); }
public static SUTime.Time getCurrentTime() { return new GroundedTime(new DateTime()); }
public Time intersect(Time t) { if (t.getRange().contains(this.getRange())) { return this; } else { return null; } }
public Temporal intersect(Temporal other) { if (other == null) return this; if (other == TIME_UNKNOWN) return this; if (other.getRange().contains(this.getRange())) { return this; } else { return null; } }
public Value apply(CoreMap m) { try { String str = m.get(textAnnotationField); // TODO: Allow specification of pivot year (withPivotYear) for interpreting 2 digit years DateTime d = formatter.parseDateTime(str); return new Expressions.PrimitiveValue("GroundedTime", new SUTime.GroundedTime(d)); } catch (IllegalArgumentException ex) { return null; } } }
public Time add(Duration offset) { Period p = offset.getJodaTimePeriod(); GroundedTime g = new GroundedTime(base.toInstant().withDurationAdded(p.toDurationFrom(base), 1)); g.approx = this.approx; g.mod = this.mod; return g; }
public Time add(Duration offset) { Period p = offset.getJodaTimePeriod(); GroundedTime g = new GroundedTime(base.toInstant().withDurationAdded(p.toDurationFrom(base), 1)); g.approx = this.approx; g.mod = this.mod; return g; }
public Time intersect(Time t) { if (t.getRange().contains(this.getRange())) { return this; } else { return null; } }
@Override public Temporal intersect(Temporal other) { if (other == null) return this; if (other == TIME_UNKNOWN) return this; if (other.getRange().contains(this.getRange())) { return this; } else { return null; } }
@Override public GroundedTime setTimeZone(DateTimeZone tz) { MutableDateTime tzBase = base.toInstant().toMutableDateTime(); tzBase.setZone(tz); // TODO: setZoneRetainFields? return new GroundedTime(this, tzBase); }
@Override public Value apply(CoreMap m) { try { String str = m.get(textAnnotationField); // TODO: Allow specification of pivot year (withPivotYear) for interpreting 2 digit years DateTime d = formatter.parseDateTime(str); return new Expressions.PrimitiveValue("GroundedTime", new SUTime.GroundedTime(d)); } catch (IllegalArgumentException ex) { return null; } } }
public Temporal intersect(Temporal other) { if (other == null) return this; if (other == TIME_UNKNOWN) return this; if (other.getRange().contains(this.getRange())) { return this; } else { return null; } }
public GroundedTime setTimeZone(DateTimeZone tz) { MutableDateTime tzBase = base.toInstant().toMutableDateTime(); tzBase.setZone(tz); // TODO: setZoneRetainFields? return new GroundedTime(this, tzBase); }
public Value apply(CoreMap m) { try { // TODO: Allow specification of locale, pivot year (set2DigitYearStart) for interpreting 2 digit years String str = m.get(textAnnotationField); Date d = format.parse(str); return new Expressions.PrimitiveValue("GroundedTime", new SUTime.GroundedTime(new Instant(d.getTime()))); } catch (java.text.ParseException ex) { return null; } } }
@Override public Time add(Duration offset) { Period p = offset.getJodaTimePeriod(); GroundedTime g = new GroundedTime(base.toInstant().withDurationAdded(p.toDurationFrom(base), 1)); g.approx = this.approx; g.mod = this.mod; return g; }
@Override public Time intersect(Time t) { if (t.getRange().contains(this.getRange())) { return this; } else { return null; } }
@Override public Value apply(CoreMap m) { try { // TODO: Allow specification of locale, pivot year (set2DigitYearStart) for interpreting 2 digit years String str = m.get(textAnnotationField); Date d = format.parse(str); return new Expressions.PrimitiveValue("GroundedTime", new SUTime.GroundedTime(new Instant(d.getTime()))); } catch (java.text.ParseException ex) { return null; } }