Re: [Xsltforms-support] Date formatting
Brought to you by:
alain-couthures
From: Steven P. <ste...@cw...> - 2023-09-29 16:39:47
|
On Friday 29 September 2023 16:27:01 (+02:00), Richard Light wrote: Hi, When I have a date value in a control, the calendar picker pops up and lets me select a date. However, this is in the format 'MM/dd/YYYY', i.e. American format. xsltforms decides on the format to output dates using your environment. I get the format dd/mm/yyyy from the calendar popup, and generally any user of my XForms gets dates displayed in the form that they expect, not in the form that I expect. However, it is important to realise that how values are displayed is not necessarily how they are stored (and vice versa). Dates for instance (at least values that are declared as being of one of the date types) are always stored using the ISO format 2023-09-29, so your substring-before( ., '/') is never going to work, because they are stored using hyphens, not slashes. In general <output ref="..."/> takes types into account, and <output value="..."/> doesn't and gives you the stored value. Steven I've tried putting xml:lang="en" into various places, but this doesn't affect the outcome. Is there a special place to put xml:lang I have missed, or is this not how you control the format of selected dates? As well as switching day and month, I would really like to output the dates that the user selects in the format we recommend to our users: 'dd.mm.YYYY'. I've tried writing a <setvalue> command, but to no avail: <action ev:event="xforms-ready"> <setvalue ref="ProcedureTemplate/Object/Movement/DateRequested" value="concat(substring-before(substring-after(., '/'), '/'), '.', substring-before(., '/'), '.', substring-after(substring-after(., '/'), '/'))"/> </action> Is this approach doomed to failure, or have I just made a minor coding error? Thanks, Richard -- Richard Light ric...@gm... <mailto:ric...@gm...> @richardofsussex |