Search

Hi all,

I'm trying to use the default date-time utility to convert an ISO date, but I'm getting a big fat 'NaN' for the time.

I'm feeding in a standard ISO date, as such:

2013-02-01T08:15:30+00:00

With the following:

<xsl:call-template name="format-date">
   <xsl:with-param name="date" select="date"/>                                                      
   <xsl:with-param name="format" select="'d-n-Y t'"/>
</xsl:call-template>

The output reads:

01-02-2013 NaN:pm

Anybody able to confirm if this is a bug, or expected behavior? If it's expected any idea how I can make it work with a standard ISO date?

Waves into the empty room

That is a good point, actually. The problem is that the default date-time.xsl file is expecting the Symphony XML format rather than a complete ISO date/time format. In Symphony, the date field outputs the following:

<date time="21:56" weekday="2">2013-02-05</date>

So, line 96 of the date-time.xsl file is looking for the @time attribute.

<xsl:with-param name="time" select="$date/@time"/>

So, what you need is a little modification, so that the utility is working with the time from the complete ISO date format.

<xsl:with-param name="time" select="substring($date, 12, 8)"/>

The default date-time template does not expect a value for seconds. Again, it is expecting the Symphony date field XML, which (for whatever reason) does not include seconds. So, you may need to adjust the format-time template as needed.

It looks like the Format Date/Time Advanced utility does handle times with seconds, but it also needs to be adjusted to deal with the ISO date format you are using.

Thanks for the info bauhouse - makes sense that it's looking for the format Symphony outputs.

Darn, will have a poke around, was hoping to avoid delving into the nitty-gritty. Unfortunately these dates are coming from an external source so I'll have to make them play some how.

We have our own date and time utility in our studio's XSLT Kit which might help you: https://github.com/hananils/kit/blob/master/datetime.xsl#L132-L153

Ooh, thanks Nils, will check it out!

Edit: Spot on, works a treat - Thanks!

Thanks for that, Nils! I forgot about your XSLT Kit. That would be so valuable to have in the XSLT Utilities on this site. It would be so great to make these resources easier to find on the new site.

Just so you know: if you seek dates with written month or day names, you'll need the Data Source provided with the Date and Time extensions which also offers localisations.

That would be so valuable to have in the XSLT Utilities on this site.

Certainly – the problem is that it's currently too much work to keep all these components up-to-date on this site. An automated system like on the extensions site would really be helpful. And maybe a standardised way how to provide utilities (Github repos, Gists).

Ah, and before I forget, John created his own set of utilities that extend our Kit: https://github.com/designermonkey/utility-monkey

Thanks for the link Nils!

Mine are crap though. ;)

Got so many updates to push locally, but no time to prepare the load.

What is this 'time' you speak of? ;)

Some weird concept I heard of that was linked with another word, free. I think it was 'time free' or 'free time'? Yeah that was it, 'free time'.

Weird.

free time

Dreamer.

I'm using the date time utility from Nils but it doesn't show the year

<xsl:call-template name="datetime">
 <xsl:with-param name="date" select="datum/date/start" />
 <xsl:with-param name="format" select="'W d-n-Y T'"/>
</xsl:call-template>

Result: woensdag 07-11- 11:48

EDIT, this seems to be a server (configuration?) issue.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details