Friday, July 18, 2014

Guidelines for using the W3C Time ontology


This post contains some guidelines in form of recipes that can help in using the W3C Time ontology to represent time instants and intervals. Even if the focus is on a single ontology, similar approaches could be followed to represent time entities using other ontologies.

The next figure shows the main classes and properties of the Time ontology. For every entity the namespace is http://www.w3.org/2006/time.




Recipe 1. Representing time instants



Time instants can be represented using the Instant class and the inXSDDateTime property. The figure below shows an example of representing the instant for the time 19:30:05 on July 18th 2014.






The ontology allows an alternative way of representing instants, by relating an instant with a certain interval description (DateTimeDescription) using the inDateTime property. However, this representation only allows to approximate the instant by confining it to an interval, so it is not advised to follow it in order to describe time instants.

Recipe 2. Representing time intervals


Time intervals can be represented using the Interval class and the hasBeginning and hasEnd properties, which refer to the instant in which the interval starts and ends, respectively. The figure below shows an example of representing the interval for June 2014.






Usually, we are only interested in representing proper intervals, which are intervals whose extremes are different. Among other things this allows using standard interval calculus and to define relations between intervals. We could have defined the interval in the previous figure using the ProperInterval class as follows, since it is a proper one.





The ontology also allows to represent intervals with a higher level of granularity by means of the DateTimeDescription class and its related properties. One advantage of this representation is that it allows to represent more information about the interval, i.e., the day of the week, the day of the year, or the week. The figure below shows an example of representing the interval for June 2014 using the DateTimeDescription class.






Recipe 3. Representing relations between time intervals


As mentioned above, we can define different relationships between proper intervals, such as if they are equal, if they overlap, and so on. As an example, the next figure represents two intervals and states that one comes before the other.




Recipe 4. Representing time interval durations


The way of modelling the duration of a proper interval (the duration of non-proper ones will be 0) is by using the DurationDescription class and its related properties. The figure below represents the duration of the interval for June 2014 in terms of months and days.


These recipes provide a fast way of getting to grips with the use of the W3C Time ontology in different frequent modelling needs. Clearly, time modelling may lead to things much more complicated than those presented here and that are out of the scope of this post. Time zones can be represented using the Time ontology with the Time Zone ontology (described in the same note as the Time ontology). Other characteristics can be represented by extending the Time ontology, such as convex and non-convex intervals or infinity (unbounded) intervals. Other potential particularities are not covered by the ontology, such as representing open and closed intervals or representing absolute and relative time.