Pick and Format Dates or Times
With macro input parameters that are dates or dates and times, you can have Wires provide a date and time control to make it easier for users to enter dates or dates and times. You can also optionally control the format of the date and time. Your choices for handling dates and times depends on the datatype you use for the macro input parameter:
datetime: this is generally the best choice for an input parameter that is a date or datetime, with some limitations. This datatype supports date comparisons, sorting or XPath date math functions. However, values for dates and times
must use the standard format:
yyyy-mm-ddThh:mm:ss[.sss zzzzzz
Note: | This format is the datetime datatype in the XML Schema standard, which is based closely on the ISO 8601 standard. |
For dates in this format, years are four digits and both month and days are two digits. Times have two digit hours, minutes and seconds, using a 24-hour clock, with optional milliseconds and a GMT time zone. If no time is specified, this defaults to 00:00:00 (Midnight) and the time zone for the current user.
Dates and times are separated with a literal T. Times and time zone are separated by a space.
To provide a date and time control for a block property with a datetime datatype, add the macro metadata element <type> in <parameter> with a datatype of datetime:
<macros xmlns="http://www.open-mashup.org/schemas/v1.0/EMML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML/..
/schemas/EMMLPrestoSpec.xsd"
domain="myBlocks">
<macro name="helloWorld"
xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions"
xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro">
<input name="aDateTime" type="datetime"/>
...
<presto:macro-meta>
<block usage="Wires">
...
</block>
<parameters>
<parameter name="aDateTime">
<label>Choose a date and time</label>
<type datatype="datetime"/>
</parameter>
...
</parameters>
</presto:macro-meta>
....
</macro>
...
</macros>
The date and time control that Wires uses in this case is:
string: you can also pass dates or times in input parameters using the
string datatype. This is typically most useful when the date or time input parameter is used within the macro for the block as an input to a mashable, mashup or some other information source that requires a format that does not match the standard
datetime format. (See previous
datetime discussion.)
With a string input parameter, you can provide a date and time control. You can also control the format that the chosen date and time uses.
The limitation with a string datatype for dates and times is that it does not support date sorting, date comparisons or XPath date math functions.
To provide a date and time control for a block property with a string datatype, add the macro metadata element <type> in <parameter> with a datatype of datetime. To define the format for the input parameter value, add the macro metadata element <datetimefield> in <type>. The metadata would look something like this:
<macros xmlns="http://www.open-mashup.org/schemas/v1.0/EMML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML/..
/schemas/EMMLPrestoSpec.xsd"
domain="myBlocks">
<macro name="helloWorld"
xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions"
xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro">
<input name="aStringDate" type="string"/>
...
<presto:macro-meta>
<block usage="Wires">
...
</block>
<parameters>
<parameter name="aStringDate">
<label>Choose a future date</label>
<type datatype="datetime">
<datetimefield format="m/d/yy"/>
</type>
</parameter>
...
</parameters>
</presto:macro-meta>
....
</macro>
...
</macros>
The format attribute defines a template for the format to use with this input parameter. This example would output just a date with a 1-2 digit month, 1-2 digit day and a four digit year.
The format can specify just dates or both dates and times. You can also use either a 24-hour or 12-hour clock for times.
Valid format characters include:
/ or - | To separate the components in a date. |
: | To separate components in a time. |
space or any non-token character | Between dates and times or between times and a suffix or time zone. For example: mm/dd/yyyyThh:mm displays a date and time such as 03/05/2012T22:06 d-m-yyyy hh:mm:ss TTZ displays a date, time and time zone such as 5/3/2012 10:06:15 PM-0700 |
y | For a two digit year. |
yy | For a four digit year. |
m | For a 1-2 digit month (no leading zeros). |
mm (for dates) | For a two digit month (leading zeros if needed). |
M | For a short month name. |
MM | For a long month name |
d | For a 1-2 digit day (no leading zeros). |
dd | For a two digit day (leading zeros if needed). |
D | For a short day of the week. |
DD | For a long day of the week. |
o | For 1-2 digits for the day of the year (no leading zeros). |
oo | For two digits for the day of the year (leading zeros if needed). |
hh | For a two digit hour (leading zeroes if needed). Times are optional. Both hour and minute are required if times are in the format. |
mm (for times) | For a two digit minute (leading zeros if needed). Times are optional. Both hour and minute are required if times are in the format. |
ss | For a two digit second. Seconds are optional in times. |
TT or tt | If this time should be based on a 12-hour clock, this is the form of the suffix to use: AM | PM or am | pm respectively. |
Z | To include a GMT time zone for times. |