ON THIS PAGE:
The Time components provide a way to work with time periods and timestamps of data points.
Add Seconds
The Add Seconds component adds seconds to a timestamp. You can use this to create a time offset in a process.
Properties
This component has no additional properties.
Inputs
The component that acts as a trigger for this component should be connected to this pin.
The timestamp passed by the pin of the connected component. This input is required. Not connecting this pin will produce an error.
The number of seconds to add to the timestamp. For example, 120 (120 seconds). To subtract time from the timestamp, use a negative symbol (-), for example, -120. This input is required. Not connecting this pin will produce an error.
Outputs
The resultant timestamp, which has been incremented (or decremented, if a negative number is used) by the specified number of seconds.
Example
In the following example, the input data is compared with the data from 60 seconds earlier to see if it is above or below. The input stream is split into two to retrieve the current value and the previous value.
The previous value is obtained by adding 60 seconds to the data's timestamp. This gives us the point in time for which we want to get the value.
We will use that timestamp as an end point and retrieve a 24-hour window worth of values up to that point. We will then take the last value from that 24-hour window worth of data. This is the value that we will use for comparison.
We then compare that value with the current value obtained by the Get Single component.
Add Time Period
The Add Time Period component adds a time period to a timestamp. You can use this to create a time offset in a process.
Properties
This component has no additional properties.
Inputs
The component that acts as a trigger for this component should be connected to this pin.
The timestamp passed by the pin of the connected component. This input is required. Not connecting this pin will produce an error.
The period of time to add to the timestamp. For example, 1 hour. This input is required. Not connecting this pin will produce an error.
Outputs
The resultant timestamp, which has been incremented by the specified time period.
Example
In the following example, the input data is compared with the data from the previous day to see if it is above or below. The input stream is split into two to retrieve the current value and the previous value.
The previous value is obtained by adding a time period of 1 day to the data's timestamp. We must put a negative symbol to indicate we want to go back in time to get the value from the previous day. This gives us the point in time for which we want to get the value of.
We will use that timestamp as an end point and retrieve a minute's worth of values up to that point. We will then take the last value from that minute's worth of data. This is the value that we will use for comparison.
We then compare that value with the current value obtained by the Get Single component.
Now
The Now component retrieves the current timestamp and sends it to the connecting component. This component should only be used with the Log component, to log a message at the current timestamp as opposed to the timestamp of the entity.
Properties
This component has no additional properties.
Inputs
The component that acts as a trigger for this component should be connected to this pin.
Outputs
The current timestamp.
Example
In the following example, the Now component is used to obtain the current timestamp, which is converted to text and joined into one string that is ultimately sent to the logging infrastructure.
Set Timestamp
The Set Timestamp component sets the timestamp of the input to the specified timestamp.
Properties
This component has no additional properties.
Inputs
The component that acts as a trigger for this component should be connected to this pin.
The input value.
The timestamp that you want to set for the input.
Outputs
The data point with the new timestamp. Not connecting this output pin will produce a warning.
Example
In the following example, the temperature is compared against a maximum value. If the temperature is greater than the maximum, an event is raised, the state of the entity changes to Above, and a value of 0 is written to the entity. The Set Timestamp component gives to the value the timestamp of the entity used to supply the Temperature input.
Text → Time
The Text → Time component parses a string and converts it into its equivalent timestamp. The timestamp is in UTC format.
Properties
This component has no additional properties.
Inputs
The component that acts as a trigger for this component should be connected to this pin.
The string that is to be converted into a timestamp. This input is required. Not connecting this pin will produce an error. The string should have the following format:
yyyy-M-d h:mm:ss tt
E.g. 2014-12-1 12:00:00 AM
Outputs
The timestamp produced by the component after parsing the input string.
If the string cannot be converted to a time format, the process follows this path. No data is passed to the connected component. This pin is optional. Not connecting this pin will produce a warning. If this pin is not connected, the process will abort if an error is encountered.
Example
In the following example, the user inputs a string to use as a timestamp. The Text → Time component converts this to a timestamp to send to the rest of the process. If the conversion cannot happen, a message is logged.
Text → Time Period
The Text → Time Period component parses a string and converts it into its equivalent time period. The time period is in UTC format.
Properties
This component has no additional properties.
Inputs
The component that acts as a trigger for this component should be connected to this pin.
The string that is to be converted into a time period. This input is required. Not connecting this pin will produce an error. The string should have the following format:
<years>y<months>m<weeks>w<days>d<hours>h<minutes>mi<seconds>s<milliseconds>ms
e.g. 2y5m2w3d13h54mi12s0ms
Outputs
The time period produced by the component after parsing the input string.
If the string cannot be converted to a time period format, the process follows this path. No data is passed to the connected component. This pin is optional. Not connecting this output pin will produce a warning. If this pin is not connected, the process will abort if an error is encountered.
Example
In the following example, the user inputs a string to use as a time period. The Text → Time Period component converts this to a time period to send to the rest of the process. If the conversion cannot happen, a message is logged.
Time → Text
The Time → Text component formats a timestamp as a string.
Properties
Timestamp Format
You can choose to format the timestamp in two ways:
- d/M/yyyy h:mm:ss tt
E.g. 13/11/2014 13:00:00 AM (where tt is AM or PM) - UTC
The date and time in Coordinated Universal Time. E.g. 2014-11-13T13:00:00+08:00.
Inputs
The component that acts as a trigger for this component should be connected to this pin. This pin is optional.
The timestamp that is to be converted to text.
Outputs
The text conversion of the timestamp.
Example
In the following example, the current time is retrieved by the Now component, and is converted to text so that it can be logged.
Time Difference
The Time Difference component produces a time period that represents the difference between the two timestamp inputs.
Properties
This component has no additional properties.
Inputs
The component that acts as a trigger for this component should be connected to this pin.
The start timestamp of the time period. This input is required. Not connecting this pin will produce an error.
The end timestamp of the time period. This input is required. Not connecting this pin will produce an error.
Outputs
The time period that represents the difference between the two inputs.
Example
In the following example, the Time Difference component retrieves the timestamp of Input 2 and reads the timestamp of Input 1 from memory. It produces a time period, which is used as the input for a Boolean operator that evaluates if the difference between the two time stamps is greater than 2 minutes.
Time Period → Text
The Time Period → Text component converts a time period to string format.
Properties
This component has no additional properties.
Inputs
The component that acts as a trigger for this component should be connected to this pin.
The time period that is to be converted to text. This input is required. Not connecting this pin will produce an error.
Outputs
The text representation of the time period.
Example
In the following example, a time period value is obtained by getting the time range from the first data point to the last data point in the data set. The resulting time period is logged in the logging infrastructure.