|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--galaxy.lang.DateUtil
This class encapsulates a set of static functions for manipulating dates and semantic frames.
Predicate
Field Summary | |
static int |
defaultYear
The current year. For example: 1998. |
Method Summary | |
static boolean |
after(GFrame dfr1,
GFrame dfr2)
Return true if the first date frame is after the second date frame. |
static boolean |
before(GFrame dfr1,
GFrame dfr2)
Return true if the first date frame is before the second date frame. |
static boolean |
equals(GFrame dfr1,
GFrame dfr2)
Return true if the first date frame is the same as the second date frame. |
static void |
insertDate(GFrame frame,
java.util.Calendar cal)
Parse dateString and insert the appropriate predicates into the frame representing that date and time. |
static void |
main(java.lang.String[] args)
For testing only. |
static Predicate |
makeDateFrame(GFrame fr)
Construct a date frame from the frame that tina generates. |
static boolean |
monthEquals(GFrame dfr,
GFrame mfr)
Return true if the month in both frames is non-null and the same value. |
static Predicate |
parseDate(java.lang.String str)
Parse a date string and produce the corresponding GFrame. |
static GVector |
prepareDates(GFrame tinaFrame,
boolean silent)
Generate a GVector of date frames from a tina frame. |
static void |
prepareTimesForSQL(GFrame f,
int zoneOffset)
Locate time predicates, and convert them from relative time to absolute time useful for sql queries. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int defaultYear
Method Detail |
public static void prepareTimesForSQL(GFrame f, int zoneOffset) throws TimeRangeMakerException
Predicates which are converted are: start_time, end_time, before, after, at and time_interval.
For example, assume today is Friday May 15, 1998
:pred {p month_date :topic {q date :day "saturday" :exists 1 } } |
:pred {p absolute_start_time :topic {q absolute_tod :year 1998 :month "may" :dom 16 :hour 0 :minute 0 } } :pred {p absolute_end_time :topic {q absolute_tod :year 1998 :month "may" :dom 16 :hour 23 :minute 59 } } |
:pred {p month_date :topic {q date :day "weekend" :exists 1 } } } |
:pred {p absolute_start_time :topic {q absolute_tod :year 1998 :month "may" :dom 16 :hour 0 :minute 0 } } :pred {p absolute_end_time :topic {q absolute_tod :year 1998 :month "may" :dom 17 :hour 23 :minute 59 } } |
saturday 3:00 pm |
:pred {p absolute_time :topic {q absolute_tod :year 1998 :month "may" :dom 16 :hour 3 :minute 0 } } | /
This is a grammar of time predicates we handle as input.
<tina_time> :=<time_preds> |<time_relation> |<time_preds> <time_relation> <time_relation> := <start_end> | <after> | <before> | <at> <start_end> := ;;Generated when the user says "between". :pred {p start_time ;;Inclusive <complex_time>} :pred {p end_time <complex_time>} <after> := :pred {p after ;;Exclusive <complex_time>} <before> := :pred {p before ;;Exclusive <complex_time>} <at> := :pred {p at :topic <time>} <complex_time> := [(<at> | :topic <time>)] [(<month_date> | :topic <date>)] [(<time_interval> | :topic <time_of_day>)] <time_preds> := <month_date> <time_interval> <at> ;; One or more of these. <month_date> := :pred {p month_date :topic <date> } <date> := {q date :day <dow> } <time_interval> := :pred {p time_interval :topic {q time_of_day :name <interval> } } <time> = {q time <hour> :minutes # [:xm "a m"]} <hour> := :hour # | :military # <interval> := "morning" | "night" | "afternoon" | "evening" <dow> := "weekend" | "monday" | "tuesday" | "wednesday" | "thursday" | ...
public static GVector prepareDates(GFrame tinaFrame, boolean silent)
year | The full year. |
month | The number of the month. 1 == January |
day | Day of the month. |
wday | Day of the week. 1 == Sunday. |
yday | Day of the year. |
If the tina frame designates a day of the week, then wday field is added designating the day of the week as an integer. The name of the day is carried over. Note a name for the day of the week is not generated if the date is given as month, day. Presumably this is for language generation reasons. Answer in the manner the question was asked.
Tina frame | Date frame |
---|---|
{p date :day "saturday"} |
({p date :wday 7 :day_name "saturday"}) |
{p date :name "today"} |
({p date :year 1998 :name "today" :wday 3 :yday 153 :day 2 :month 6}) |
{p date :name "weekend"} |
({p date :wday 7 :day_name "saturday"} {p date :wday 1 :day_name "sunday"} ) |
{p date :month "may" :day_number 15} |
({p date :year 1998 :wday 6 :yday 135 :day 15 :month 5}) |
tinaFrame
- The tina framesilent
- If true insert :silent 1
in to the frame. Otherwise remove :silent
public static Predicate parseDate(java.lang.String str)
The date string can contain a month name, day of the week name, and/or an integer. If the integer is less than 32, it is considered the day of the month. If it is less than 100 it is considered the last two digits of the year. Otherwise it is considered the year.
Predicate
public static boolean monthEquals(GFrame dfr, GFrame mfr)
public static boolean before(GFrame dfr1, GFrame dfr2)
public static boolean after(GFrame dfr1, GFrame dfr2)
public static boolean equals(GFrame dfr1, GFrame dfr2)
public static Predicate makeDateFrame(GFrame fr)
If input frame contains | then process output frame |
---|---|
:day_number | add :day, and :day_name |
:year | copy to date frame. |
:month with name | add :month with number. |
:day | add :wday and :day_name to date frame. |
public static void main(java.lang.String[] args)
public static void insertDate(GFrame frame, java.util.Calendar cal) throws java.text.ParseException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |