eventsOnDay.n3 2.52 KB
@prefix dc: <http://purl.org/dc/elements/1.1/>.

<> dc:description """eventsOnDay -- find events on a given day
""",
"$Id: eventsOnDay.n3,v 1.2 2003/07/08 22:59:10 connolly Exp $".

@prefix ical: <http://www.w3.org/2002/12/cal/ical#>.

@prefix str: <http://www.w3.org/2000/10/swap/string#> .
@prefix os: <http://www.w3.org/2000/10/swap/os#> .
@prefix time: <http://www.w3.org/2000/10/swap/time#> .
@prefix math: <http://www.w3.org/2000/10/swap/math#> .

@prefix log: <http://www.w3.org/2000/10/swap/log#> .
@prefix k: <http://opencyc.sourceforge.net/daml/cyc.daml#>.
@prefix dt: <http://www.w3.org/2001/XMLSchema#>.

@prefix    : <http://www.w3.org/2000/12/cal/eventsOnDay#>.
@prefix eon: <http://www.w3.org/2000/12/cal/eventsOnDay#>.

@prefix the: <http://www.w3.org/2002/12/cal/the@@#>.

##
# grab date from command line... use --with 2003-07-08
#

:arg :index "1", "2", "3", "4".

{
  [ is :index of :arg] os:argv ?YMD.
  ?D log:uri
    ("http://www.w3.org/2002/12/cal/the@@#Day" ?YMD).str:concatenation.
} => { ?D a k:Date, k:CalendarDay, :CommandLineDay; dt:date ?YMD }.



####
# partition Vevents among several classes...

# a bit of RDFS...
@prefix s: <http://www.w3.org/2000/01/rdf-schema#>.
{ ?S [ s:domain ?C ] [] } => { ?S a ?C }.

{ ?E ical:dtstart [ ical:date [] ] } => { ?E a :AllDayEvent }.
{ ?E ical:dtstart [ ical:dateTime [] ] } => { ?E a :TimedEvent }.

ical:dtend s:domain :TimedEndEvent.
ical:duration s:domain :FixedDurationEvent.

ical:rrule s:domain :RecurringEvent.
#@@ hm... how to tell that something is *not* a recurring event...


###
# :TimedEvent, :TimedEndEvent

{
  ?D a k:CalendarDay.

  ?E.ical:dtstart.ical:dateTime str:startsWith ?D.dt:date.
}
 => { ?D k:temporalBoundsIntersect ?E }.

{
  ?D a k:CalendarDay; k:temporalBoundsIntersect ?E.

  ?E.ical:dtend.ical:dateTime str:startsWith ?D.dt:date.
}
 => { ?D k:temporallySubsumes ?E }.


###
# :TimedEvent, :FixedDurationEvent
#@@

###
# :FixedDurationEvent, :AllDayEvent.

{
  ?D a k:CalendarDay.

  ?E.ical:dtstart.ical:date str:notGreaterThan ?D.dt:date.

  (?E.ical:duration "^P(\\d+)D$") str:scrape ?DUR.

  (24 60 60) math:product ?SECS_PER_DAY.


  (
   (?D.dt:date.time:inSeconds ?SECS_PER_DAY).math:integerQuotient
   (?E.ical:dtstart.ical:date.time:inSeconds ?SECS_PER_DAY).math:integerQuotient
  ) math:difference ?DELTA.

  ?DELTA math:notLessThan 0.
  ?DELTA math:notGreaterThan ?DUR.

}
 => { ?D k:temporalBoundsIntersect ?E }.


<> dc:description """
$Log: eventsOnDay.n3,v $
Revision 1.2  2003/07/08 22:59:10  connolly
pruned some junk.
starting to work on more cases

""".