SPARK Documentation

Module Name: SPARK
Organization(s): SRI International
Author/Contact(s): Ken Conley

This document applies to SPARK version 0.8.x

iCalendar utilities in SPARK

The preferred date, time, and duration format within SPARK is iCalendar. Those unfamiliar with the iCalendar date format should refer to the online specification (RFC 2445).

The SPARKDOC for utilities.ical lists the currently available actions, predicates, and functions that support use of this format.

Example code

importall: utilities.ical
main: testcal

{defaction (testcal $args)}

{defprocedure "testcal"
   cue: [do: (testcal $args)]
   precondition: (ground $args)
   body: [seq:
	  [do: (print "Starting test" [])]
	  [set: $start "20041225T090000Z"]
	  [do: (setCurrentTime $start)]
	  [do: (print "current time set, now %s" [(getCurrentTime)])]
	  [do: (sleep 5)]
	  [set: $now (getCurrentTime)]
	  [set: $diff "PT5S"]
	  [do: (print "time is %s" [$now])]
	  [do: (print "t0+d=%s" [(addDuration $start $diff)])]
	  [do: (print "t1-d=%s" [(subtractDuration $now $diff)])]
	  [do: (print "d+d=%s" [(durationAddDuration $diff $diff)])]
	  [do: (print "d-d=%s" [(durationSubtractDuration $diff $diff)])]
	  [do: (print "PT1H=%s minutes" [(durationMinutes "PT1H")])]
	  ]}

Output

starting test
current time set, now 20041225T090000Z
time is 20041225T090005Z
t0+d=20041225T090005Z
t1-d=20041225T090000Z
d+d=PT10S
d-d=P
PT1H=60 minutes
EXECUTOR TERMINATING