Date/Time Formatting

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Date/Time Formatting

brock.parker
Is there an example somewhere that shows how to change the accepted date and time format for a field?  For example, the default time format is 09:30:32.  I would like to use a time without the seconds.

I have found some settings in the properties.xml file, but changing them does not seem to help.  I have also played around with the xxforms:format-time function, but I have had no luck.  Below is my example:

properties.xml
---------------------------------
<property as="xs:string"  name="oxf.xforms.format.time"                          value="if (. castable as xs:time) then format-time(xs:time(.), '[H01]:[m01] UTC', 'en', (), ()) else ."/>

model.xml
---------------------------------
<xforms:bind id="time-a" nodeset="/new_periop_screen/aldretetime/column0" type="xs:time"/>

view.xhtml
---------------------------------
<xforms:input bind="time-a" xhtml:style="width:70;height:20;" />

If I submit the form with a time in the HH:mm format, I get the error "Please correct the errors on this page."

Thanks,

Brock Parker



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Date/Time Formatting

Erik Bruchez
Administrator
Brock,

The setings in properties only control the formatting of dates and
times on output, not on input.

I think there are two questions:

1. Do you want a different format stored into your XML document.

2. Do you want a different format entered by the user.

In both cases, currently, the OPS XForms engine does not have
flexibility of format to enter dates. This kinds of relates to
Richard's wish for input masks. You should be able to specify an input
format for dates, and then have OPS automatically validate the user
entry according to that mask.

In the meanwhile, you will have to do this by hand, i.e. validate the
user input yourself (with an XML Schema or XPath contraint).

Note that as far as the actual data format store into the XML
document, it remains good practice to use the standard XML formats.

-Erik

[hidden email] wrote:

 > Is there an example somewhere that shows how to change the accepted
 > date and time format for a field?  For example, the default time
 > format is 09:30:32.  I would like to use a time without the seconds.
 >
 > I have found some settings in the properties.xml file, but changing
 > them does not seem to help.  I have also played around with the
 > xxforms:format-time function, but I have had no luck.  Below is my
 > example:
 >
 > properties.xml
 > ---------------------------------
 > <property as="xs:string"  name="oxf.xforms.format.time"
             value="if (. castable as xs:time) then
format-time(xs:time(.), '[H01]:[m01] UTC', 'en', (), ()) else ."/>
 >
 > model.xml
 > ---------------------------------
 > <xforms:bind id="time-a"
nodeset="/new_periop_screen/aldretetime/column0" type="xs:time"/>
 >
 > view.xhtml
 > ---------------------------------
 > <xforms:input bind="time-a" xhtml:style="width:70;height:20;" />
 >
 > If I submit the form with a time in the HH:mm format, I get the
 > error "Please correct the errors on this page."
 >
 > Thanks,
 >
 > Brock Parker




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws