Contents: MashupHub User and Administrator Guide : Mashup Center 2.0
The Add DateTime Duration function adds a datetime interval to a datetime value.
For example, use the Add DateTime Duration function to find all entries published during the first week of the year.
The datetime value to which you want to add the duration.
For the Input
parameter you can:
- Specify a text value.
- Specify a function value.
- Use a variable to return the value.
- Specify a value from the Input tree.
value must be a datetime value or a string that can be cast to a datetime using one of the default formats. If it is not already a datetime or is not in a default format, first convert it using the Create DateTime function.
The number of years as an integer >= 0. This value to initialized to 0.
The number of months as an integer >= 0. This value to initialized to 0.
The number of days as an integer >= 0. This to initialized to 0.
The number of hours as an integer >= 0. This value to initialized to 0.
The number of minutes as an integer >= 0. This value to initialized to 0.
The number of seconds as an integer or decimal >= 0. This value to initialized to 0.0.
Each value must be >= 0. Negative values are ignored.
A new datetime value.
This example shows how to use the Filter operator and the Add DateTime Duration function to find all entries that were published during the first week of January 2009.
Assume a feed has a pubDate
element in RSS format:
<pubDate>Fri, 02 Jan 2009 21:45:17 +0000</pubDate>
Follow these steps to find all entries that were published during the first week of January 2009:
- Add the Filter operator to the canvas. You will add two filter conditions.
- The first filter condition searches for all entries >= January 1, 2009:
- For the Input element, specify the pubDate element in the Input tree.
- Right-click the pubDate value and choose "Date" to cast the value to a Date.
- Select >= for the Comparison.
- For the Value, enter "2009-01-01".
Because you explicitly cast the Input element to Date, MashupHub will attempt to cast the Value to a date also. This action succeeds if you enter the date value in one of the default formats, such as RSS or Atom. This example entered the date in Atom format.
- Click the plus sign (+) to add the second filter condition. The second filter condition searches for all entries <= January 1, 2009 + 1 week.
- For the Input element, again specify the pubDate element in the Input tree. It should already be marked as a Date.
- Select <= for the Comparison .
- For the Value, select the Add DateTime Duration function.
- For the Input parameter, enter "2009-01-01".
Because the date is in Atom format, which is one of the supported default formats, you do not need to cast it.
- Enter 7 in the Day field. Leave the rest of the fields set to 0.
The parameters in the Add DateTime Duration function dialogue will be the following.
Table 1. Add DateTime function parameters
- Click OK. The filter conditions will be the following.
Table 2. Filter conditions
When the filter condition runs, all datetime values in the feed are converted to the time zone of the JVM on which MashupHub is installed. The datetime value at the start of this example, Fri, 02 Jan 2009 21:45:17 +0000, was generated in the Coordinated Universal Time (UTC) time zone. That datetime value is converted to the local time zone, then the comparison to January 1 2009 + 7 days is performed.
Parent topic: Functions : Mashup Center 2.0
Functions : Mashup Center 2.0
Supported date formats : Mashup Center 2.0