Common Lisp Package: CHRONICITY

README:

FUNCTION

Public

PARSE (TEXT &KEY ((CONTEXT *CONTEXT*) *CONTEXT*) ((NOW *NOW*) (OR *NOW* (NOW))) (GUESS *GUESS*) ((AMBIGUOUS-TIME-RANGE *AMBIGUOUS-TIME-RANGE*) *AMBIGUOUS-TIME-RANGE*) ((ENDIAN-PREFERENCE *ENDIAN-PREFERENCE*) *ENDIAN-PREFERENCE*) &AUX TOKENS)

Parse the string in TEXT and return either a DATETIME or a SPAN object. Also returns a list of tokens as the second value. CONTEXT (default *CONTEXT*) can be either :PAST or :FUTURE. NOW (default *NOW* or this instant) should be a DATETIME instance, relative to which the date/time will be calculated. GUESS (default *GUESS*) if NIL, PARSE returns a SPAN object, otherwise returns the start, end or middle of the span if the it is :START, :END or :MIDDLE respectively. For AMBIGUOUS-TIME-RANGE (default *AMBIGUOUS-TIME-RANGE*), if an integer is given, ambiguous times (like 5:00) will be assumed to be within the range of that time in the AM to that time in the PM. For example, if you set it to 7, then the parser will look for the time between 7am and 7pm. In the case of 5:00, it would assume that means 5:00pm. If NIL is given, no assumption will be made, and the first matching instance of that time will be used.

Undocumented

DAY-OF (DATETIME)

DOW-NAME (INDEX)

DOW-OF (DATETIME)

HOUR-OF (DATETIME)

MAKE-DATE (YEAR &OPTIONAL (MONTH 1) (DAY 1))

MAKE-DATETIME (YEAR &OPTIONAL (MONTH 1) (DAY 1) (HOUR 0) (MINUTE 0) (SEC 0))

MAKE-TIME (HOUR &OPTIONAL (MINUTE 0) (SEC 0))

MINUTE-OF (DATETIME)

MONTH-NAME (INDEX)

MONTH-OF (DATETIME)

SEC-OF (DATETIME)

YEAR-OF (DATETIME)

Private

DAY-SEC-OF (DATETIME)

Returns the second of the day.

Undocumented

ADD-HANDLER (CLASS PATTERNS FN)

CHECK-POINTER (POINTER)

CHECK-POST-TOKEN (TOKEN)

CLEAR-HANDLERS

COPY-DATE (FROM &KEY (YEAR (YEAR-OF FROM)) (MONTH (MONTH-OF FROM)) (DAY (DAY-OF FROM)))

COPY-DATETIME (FROM &KEY (YEAR (YEAR-OF FROM)) (MONTH (MONTH-OF FROM)) (DAY (DAY-OF FROM)) (HOUR (HOUR-OF FROM)) (MINUTE (MINUTE-OF FROM)) (SEC (SEC-OF FROM)))

COPY-TIME (FROM &KEY (HOUR (HOUR-OF FROM)) (MINUTE (MINUTE-OF FROM)) (SEC (SEC-OF FROM)))

CREATE-TAG (CLASS TYPE &KEY NOW)

CREATE-TOKEN (WORD &REST TAGS)

DATETIME-ADJUST (DATETIME PART VALUE)

DATETIME-DECR (DATETIME UNIT &OPTIONAL (AMOUNT 1))

DATETIME-INCR (DATETIME UNIT &OPTIONAL (AMOUNT 1))

DATETIME-MONTH+ (DATETIME AMOUNT)

DATETIME-TO-UNIVERSAL (DATETIME)

DATETIME/= (&REST ARGS)

DATETIME< (&REST ARGS)

DATETIME<= (&REST ARGS)

DATETIME= (&REST ARGS)

DATETIME> (&REST ARGS)

DATETIME>= (&REST ARGS)

DEALIAS-AND-DISAMBIGUATE-TIME (TOKENS)

DOW-INDEX (NAME)

END-OF-DAY (DATETIME)

END-OF-HOUR (DATETIME)

END-OF-MINUTE (DATETIME)

END-OF-MONTH (DATETIME)

END-OF-WEEK (DATETIME)

END-OF-YEAR (DATETIME)

FIND-CLASS-HANDLERS (CLASS)

FIND-TAG (TAG-NAME TOKEN)

FIND-WITHIN (TAGS SPAN POINTER)

GET-ANCHOR (TOKENS)

GET-REPEATERS (TOKENS)

GUESS-SPAN (SPAN GUESS)

GUESS-YEAR (MONTH DAY)

HANDLE-1 (TOKENS)

HANDLE-10 (TOKENS)

HANDLE-11 (TOKENS)

HANDLE-12 (TOKENS)

HANDLE-13 (TOKENS)

HANDLE-2 (TOKENS)

HANDLE-3 (TOKENS)

HANDLE-4 (TOKENS)

HANDLE-5 (TOKENS)

HANDLE-6 (TOKENS)

HANDLE-7 (TOKENS)

HANDLE-8 (TOKENS)

HANDLE-9 (TOKENS)

HANDLE-AMBIGUOUS-DMY (ORIGINAL-TOKENS &AUX TOKENS)

HANDLE-ORR (TOKENS OUTER-SPAN)

HANDLE-P-S-R (TOKENS)

HANDLE-R (TOKENS)

HANDLE-RMN-OD (TOKENS)

HANDLE-RMN-SD (TOKENS)

HANDLE-RMN-SD-SY (TOKENS)

HANDLE-S-R-P (TOKENS)

HANDLE-S-R-P-A (TOKENS)

HANDLE-SRP (TOKENS SPAN)

HANDLER-CLASS (HANDLER)

HANDLER-FN (HANDLER)

HANDLER-PATTERN (HANDLER)

MAKE-HANDLER (CLASS PATTERN FN)

MAKE-SPAN (START END &OPTIONAL (END-INCLUDED-P NIL))

MAKE-TICK (TIME AMBIGUOUSP)

MATCH-TOKENS (HANDLER TOKENS)

MERGE-DATETIME (DATE TIME)

MERGE-TIME-TOKENS-DAY (TOKENS DATE-START)

MONTH-INDEX (NAME)

NOW

PRE-NORMALIZE (TEXT)

PRE-PROCESS-TOKENS (TOKENS)

REMOVE-SEPARATORS (TOKENS)

SCAN-FOR-AT (TOKEN)

SCAN-FOR-COMMAS (TOKEN)

SCAN-FOR-DAY-NAMES (TOKEN &AUX (WORD (TOKEN-WORD TOKEN)))

SCAN-FOR-DAY-PORTIONS (TOKEN &AUX (WORD (TOKEN-WORD TOKEN)))

SCAN-FOR-IN (TOKEN)

SCAN-FOR-MONTH-NAMES (TOKEN &AUX (WORD (TOKEN-WORD TOKEN)))

SCAN-FOR-ON (TOKEN)

SCAN-FOR-ORDINAL-DAYS (TOKEN)

SCAN-FOR-ORDINALS (TOKEN)

SCAN-FOR-POINTERS (TOKEN)

SCAN-FOR-SCALAR-DAYS (TOKEN POST-TOKEN)

SCAN-FOR-SCALAR-MONTHS (TOKEN POST-TOKEN)

SCAN-FOR-SCALAR-YEARS (TOKEN POST-TOKEN)

SCAN-FOR-SCALARS (TOKEN POST-TOKEN)

SCAN-FOR-SLASH-OR-DASH (TOKEN)

SCAN-FOR-TIMES (TOKEN &AUX (WORD (TOKEN-WORD TOKEN)))

SCAN-FOR-UNITS (TOKEN &AUX (WORD (TOKEN-WORD TOKEN)))

SPAN+ (SPAN AMOUNT UNIT)

SPAN- (SPAN AMOUNT UNIT)

SPAN-INCLUDES-P (SPAN DATETIME)

SPAN-WIDTH (SPAN)

START-OF-DAY (DATETIME)

START-OF-HOUR (DATETIME)

START-OF-MINUTE (DATETIME)

START-OF-MONTH (DATETIME)

START-OF-WEEK (DATETIME)

START-OF-YEAR (DATETIME)

TODAY

TOKEN-HAS-TAG-P (TOKEN TAG-NAME)

TOKEN-TAG-TYPE (TAG-NAME TOKEN)

TOKENIZE (TEXT)

TOKENS-TO-SPAN (TOKENS)

UNIVERSAL-TO-DATETIME (UNIVERSAL-TIME)

MACRO

Private

Undocumented

AIF (TEST THEN ELSE)

AWHEN (TEST &BODY BODY)

DATETIME-DECF (PLACE UNIT &OPTIONAL (AMOUNT 1))

DATETIME-INCF (PLACE UNIT &OPTIONAL (AMOUNT 1))

DEFINE-HANDLER ((CLASS &OPTIONAL (NAME (GENTEMP HANDLE- CHRONICITY))) LAMBDA-LIST PATTERNS &BODY BODY)

RR-ALL-F (PLACE REGEX REPLACEMENT &REST ARGS)

GENERIC-FUNCTION

Private

SCAN (REGEX TARGET-STRING &KEY START END REAL-START-POS ((REAL-START-POS *REAL-START-POS*) NIL) (END (LENGTH TARGET-STRING)) (START 0))

Searches TARGET-STRING from START to END and tries to match REGEX. On success returns four values - the start of the match, the end of the match, and two arrays denoting the beginnings and ends of register matches. On failure returns NIL. REGEX can be a string which will be parsed according to Perl syntax, a parse tree, or a pre-compiled scanner created by CREATE-SCANNER. TARGET-STRING will be coerced to a simple string if it isn't one already. The REAL-START-POS parameter should be ignored - it exists only for internal purposes.

SCAN-TOKENS (TAG TOKENS)

Scan the list of TOKENS and tag the appropriately.

Undocumented

R-INDEX (REPEATER)

R-NEXT (REPEATER POINTER)

R-OFFSET (REPEATER SPAN AMOUNT POINTER)

R-THIS (REPEATER POINTER)

R-WIDTH (REPEATER)

TAG (TAG TOKEN)

UNTAG (TAG TOKEN)

SLOT-ACCESSOR

Public

Undocumented

SPAN-END (OBJECT)

SPAN-END-INCLUDED-P (OBJECT)

SPAN-START (OBJECT)

TOKEN-TAGS (OBJECT)

SETFTOKEN-TAGS (NEW-VALUE OBJECT)

TOKEN-WORD (OBJECT)

Private

Undocumented

TAG-NOW (OBJECT)

SETFTAG-NOW (NEW-VALUE OBJECT)

TAG-TYPE (OBJECT)

TICK-AMBIGUOUSP (OBJECT)

SETFTICK-AMBIGUOUSP (NEW-VALUE OBJECT)

TICK-TIME (OBJECT)

SETFTICK-TIME (NEW-VALUE OBJECT)

VARIABLE

Public

*AMBIGUOUS-TIME-RANGE*

The default value for :AMBIGUOUS-TIME-RANGE.

*CONTEXT*

The default value for :CONTEXT.

*ENDIAN-PREFERENCE*

The default value for :ENDIAN-PREFERENCE.

*GUESS*

The default value for :GUESS.

*NOW*

The default value for :NOW. If NIL, :NOW is assumed to be this instant.

Private

*HANDLER*

Current handler -- The one which matched the token.

Undocumented

*AFTERNOON*

*DAY-PORTIONS*

*DAYS-OF-WEEK*

*EVENING*

*HANDLERS*

*MONTHS*

*MORNING*

*NIGHT*

CLASS

Public

Undocumented

SPAN

Private

Undocumented

GRABBER

ORDINAL

ORDINAL-DAY

POINTER

REPEATER

REPEATER-DAY

REPEATER-DAY-NAME

REPEATER-DAY-PORTION

REPEATER-FORTNIGHT

REPEATER-HOUR

REPEATER-MINUTE

REPEATER-MONTH

REPEATER-MONTH-NAME

REPEATER-SEC

REPEATER-TIME

REPEATER-WEEK

REPEATER-WEEKEND

REPEATER-YEAR

SCALAR

SCALAR-DAY

SCALAR-MONTH

SCALAR-YEAR

SEPARATOR

SEPARATOR-AT

SEPARATOR-COMMA

SEPARATOR-IN

SEPARATOR-ON

SEPARATOR-SLASH-OR-DASH

TAG (TAG TOKEN)

TICK

TOKEN

CONSTANT

Private

Undocumented

+DAY-SECONDS+

+FORTNIGHT-SECONDS+

+HOUR-SECONDS+

+MINUTE-SECONDS+

+MONTH-SECONDS+

+SEC-SECONDS+

+WEEK-SECONDS+

+WEEKEND-SECONDS+

+YEAR-MONTHS+

+YEAR-SECONDS+