@prefix dc: <http://purl.org/dc/elements/1.1/> .

<> dc:description """
rules to map from travel itinerary vocabulary
to iCalendar vocabulary.
$Id: itin2ical.n3,v 1.13 2005/04/22 15:52:45 connolly Exp $
""";
    dc:source <http://www.ietf.org/rfc/rfc2445.txt> ;
    dc:relation <http://www.w3.org/2002/12/cal/ical>, <toIcal.py>,
	<http://www.w3.org/2002/12/cal/fromIcal.py>.

@prefix r: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix dt: <http://www.w3.org/2001/XMLSchema#> .

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

@prefix cal: <http://www.w3.org/2002/12/cal/icaltzd#>.
@prefix t:   <http://www.w3.org/2000/10/swap/pim/travelTerms#> .
@prefix apt: <http://www.daml.org/2001/10/html/airport-ont#>.

@prefix k: <http://opencyc.sourceforge.net/daml/cyc.daml#>.

@prefix :   <itin2ical#>.
@prefix ic: <itin2ical#>.

@prefix a: <http://www.daml.org/cgi-bin/airport?>. #hmm... ?MCI is a document *and* an airport?


# use cityLookup.n3 to map IATA codes to timezones; we no longer keep
# these here...
# a:MCI a k:Airport-Physical;
#   k:nameString "KANSAS CITY INTL";
#   :timeZone chi:tz.

{ ?DOC a k:ItineraryDocument.
  <> log:uri ?ID. } => { ?DOC a cal:Vcalendar; cal:prodid ?ID }.

{ ?DOC a k:ItineraryDocument;
    k:containsInformationAbout-Focally ?TRIP.
  ?TRIP k:subEvents ?E.
  ?E a cal:Vevent } => { ?DOC cal:component ?E }.

{
  ?TZ a cal:Vtimezone.
  ?TZ2 a cal:Vtimezone.

  ?FLT
    k:startingDate [ dt:date ?YYMMDD];
    k:endingDate [ dt:date ?YYMMDD2];
    t:departureTime ?HH_MM;
    k:fromLocation [ k:inRegion ?TZ ];
    t:arrivalTime ?HH_MM2;
    k:toLocation [ k:inRegion ?TZ2 ].
  ?DTSTART is str:concatenation of
    (?YYMMDD "T" ?HH_MM ":00") . #@@ extra punct in dates
  ?DTEND is str:concatenation of
    (?YYMMDD2 "T" ?HH_MM2 ":00") .

  (?DTSTART ?TZ) log:dtlit ?STARTT.
  (?DTEND ?TZ2) log:dtlit ?ENDT.
}
 => {
  ?FLT a cal:Vevent;
    cal:dtstart ?STARTT;
    cal:dtend ?ENDT.
}.

# withZoneInfo.n3 used to do this, but can't with new timezone design
{ ?CAL
    k:containsInformationAbout-Focally [
     k:subEvents ?E].

  ?FLT
    k:fromLocation [ k:inRegion ?TZ ];
    k:toLocation [ k:inRegion ?TZ2 ].

  ?TZ a cal:Vtimezone.
  ?TZ2 a cal:Vtimezone.
} => { ?CAL cal:component ?TZ, ?TZ2 }.



{ ?FLT
    t:carrier [ k:nameOfAgent ?CARRIER_NAME ];
    t:flightNumber ?NUM;
    k:toLocation [ apt:iataCode ?TO_NAME ].
  ?TXT is str:concatenation of
    ("#" ?NUM " to " ?TO_NAME " on " ?CARRIER_NAME).
}
 log:implies {
  ?FLT cal:summary ?TXT.
}.
