EMMLPrestoFunctions - ISODateFormatExt error parsing date

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi guys,

just wondering if this is an error or if I'm doing something wrong.

I tried to use the ISODateFormatExt function to convert the date returned from the XPath function current-date() which is returned in the form 2009-11-12+13:00. If I'm correct, in the ISO format  that should be something yyyy-MM-ddZ.

When I tried to convert this to simply dd/MM/yyyy I got the following error:

ERROR [com.jackbe.jbp.jems.client.EMMLPrestoFunctions] - <ISODateFormatExt : Parse ExceptionUnparseable date: "2009-11-12+13:00">

Cheers, Innes (NZ)

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 20 hours 36 min ago. Offline
Joined: 08/29/2008
Points: 34

I haven't tried this, but there is an XPath function that takes xs:date (which is what current-date() returns) and adjusts it to a particular timezone -- or simply removes the timezone portion, which is what you want.

The function is adjust-date-to-timezone( xs:date [,xs:dayTimeDuration]).

Hope this helps,

 

 

Sara, technical writer/jackbe

 

nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi Sara,

The following emml snippet did what I needed:

<assign outputvariable="$currentDateNoTZ"
                fromexpr="fn:ISODateFormatExt(adjust-date-to-timezone(current-date(),()),'yyyy-MM-dd',$newpubDateFormat)" />

and gave me a date in the form of dd/MM/yyyy from current-date() where $newpubDateFormat was "dd/MM/yyyy".

The key part of the call to the adjust-date-to-timezone function is to include the empty "()" as the second param. This ensures that the date returned does not include the Time Zone suffix of the date.

Cheers, Innes

smitchell
smitchell's picture
User offline. Last seen 20 hours 36 min ago. Offline
Joined: 08/29/2008
Points: 34

Cool. And thanks for the final solution. I would not have expected the second () and someone else is guaranteed to trip over it :-)

 

Sara, technical writer/jackbe