Time

The concept of time is paramount to the behavior and operations of Decision Server Insights. You must understand the units of time, what a time point is, and how you can use periods and durations to refine which events you act upon.

Using time and the ability to refer to the time of the current event enables an agent to delay and schedule when an event is processed. It also enables an agent to do the following tasks:

Time units

Time units are seconds, minutes, hours, days, weeks, months, and years. Elapsed time can be calculated in time unit change.

If you are counting days, you count the number of times the date changed. For example, if something starts on the 15th and ends on the 17th then you have a duration of two days. The date changed first to the 16th, and then to the 17th. Similarly, if you count in hours, a process that starts at 3:25 p.m. and finishes at 4:10 p.m. has a duration of 1 hour. The hour moved from 3 p.m. to 4 p.m.

Time scales

Each time unit defines a time scale. Each time scale consists of a sequence of time points. The first time point is the time origin. The distance between two successive time points in the time scale is called a time unit. A time scale is regular if it has a unique time unit. The time scale of an hour, minute, and second is regular. A regular time scale is defined by its time origin and its time unit. An irregular time scale is defined by its time origin and rules that determine the time unit between a time point of the time scale and the next. A day is not in a regular time scale because it might contain a leap second, and an hour can be removed or added following changes in Daylight Saving Time.

The time scale for months has the time units of 28, 29, 30, and 31 days and is not regular. The time scale for years has the time units of 365 and 366 days and is not regular.

Time zones

A time has different representations that depend on the time zone. A time can have different dates or different local times.

In Decision Server Insights, time operations are based on the Gregorian calendar. For example, you can test that an event happens on a certain calendar day. This calendar day is different in New York and in Paris. In New York, a calendar day starts 6 hours after Paris. Calendar operations and aggregate operations on entities use the time zone of the event time stamp.

Time points are characterized by a time instant and a time zone. Two time points for the same time instant in different time zones are different. For example, 2014-02-02T12:00:00+01:00[Europe/Paris] is the same time instant as 2014-02-02T06:00:00-05:00[America/New_York] but they are different time points. In rules, you can check whether two time points are at the same instant of time even if they belong to different zones.

The solution time zone is used as time zone for the date values and simple date values that are specified in rules and aggregates. By default, the time zone of the solution is the time zone of the server on which the solution is deployed. If you want to specify a different time zone than the time zone of the server, you can add a header in the manifest file of the solution project.

Time points

A time point is an instant of time that is measured in a time scale where the smallest unit is the second. A time point assumes that the origin of the time scale is midnight of year one in the time zone for which the time scale is defined.

A time point can be an event or a time.

Time points can be expressed as a date in the Gregorian calendar followed by the time within this day, for example: 12/31/2012 11:59:50 PM. This time point refers to the time zone of the Decision Server Insights solution. The time zone can also be specified explicitly, for example: 12/31/2012 11:59:50 PM +0100.

Time durations

A time duration is the distance between two time points. Time durations include absolute durations or calendar durations.

Absolute durations
Absolute durations measure the absolute distance between two time points in the smallest unit of measurement.
Calendar durations
Durations can be expressed in the smallest unit in a regular time scale, but they can also be expressed in time units in an irregular time scale. For example, May 15, 2003 3:30:00 PM is 3 calendar months after February 15, 2003 3:30:00 PM, and 10 calendar years after February 15, 1993 3:30:00 PM.

Time periods

A time period is an interval of time that is defined by a start time and an end time. The start time belongs to the time period, but not the end time. The start time is before or at the same time as the end time. A period has a duration that is equal to the distance between the start and end times of the period. You can also specify a time period by a start time and a duration, or an end time and a duration.

A time period contains its start time, but it does not contain its end time. For example, a calendar day is a time period of one day, starting at midnight and lasting until midnight the next day.

The following examples illustrate time periods:
  • Today
  • This month
  • The 4-hour period before the departure time
  • The year period between the start of 1980 and the start of 1990 (10 years)
  • The month period between the start of March 2012 and the start of January 2013 (10 months)
  • The day period between the start of March 12th, 2014 and the start of April 15th, 2014 (34 days)
Elementary time periods
Elementary time periods start and end at successive time points in a time scale. An elementary time period has the duration of exactly one unit and is named after the unit and the number of the time period in the time scale. Examples include the year 1980, the month February 2012, and the day February 5th, 2011.
Calendar periods

Calendar years, months, and days are time periods. For example, the calendar year 2012, the calendar month February 2013, or the calendar day December 31, 1999. In this calendar day example, the period of one day starts at 12/31/1999 00:00:00 AM and ends at 1/1/2000 00:00:00 AM.

A calendar month has a duration of 28, 29, 30 or 31 days. Adding a duration of 1 month to a time point results in another time point that is in the next month. The calendar day of this other time point is adapted if necessary. For example, 1 month after 2015-01-31T11:00Z is 2015-02-28T11:00Z and not 2015-02-31T11:00Z. February 28th is the last calendar day in 2015 and is used as the closest day to 1 month later.

Periods with a start or end and a duration
Time periods can be specified by a start or end time, and a duration. For example, the period of seven days before a flight.
Periods over multiple time units
Periods can be specified by a calendar duration over multiple time units. For example, the period of two months and two weeks after the flight. If the flight is on February 14th, 2013 9:00:00 AM, then the period of two months and two weeks starts on February 14th, 2013 9:00:00 AM and ends on April 28th, 2013 9:00:00 AM.