[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

The UNIX epoch, or time since Jan 01, 1970

Subject: The UNIX epoch, or time since Jan 01, 1970
From: Florent Georges <lists@xxxxxxxxxxxx>
Date: Mon, 21 May 2012 17:06:49 +0100 (BST)
 The UNIX epoch

  As part of sending an OAuth request to connect to Twitter, I have to
get a timestamp, as the number of seconds elapsed from Jan 01, 1970
(AKA the
UNIX epoch).  The simplest solution I could come with is the

<xsl:function name="my:current-timestamp" as="xs:string">
       <!-- the UNIX
epoch -->
       <xsl:variable name="epoch"
       <!-- time since then -->
       <xsl:variable name="diff"  select="current-dateTime() - $epoch"/>     
 <!-- all components, in seconds... -->

       <xsl:variable name="days"
 select="days-from-duration($diff) * (24*60*60)"/>
name="hours" select="hours-from-duration($diff) * (60*60)"/>
 <xsl:variable name="mins"  select="minutes-from-duration($diff) * 60"/>
 <xsl:variable name="secs"  select="floor(seconds-from-duration($diff))"/>
   <!-- sum each of them -->
       <xsl:sequence select="xs:string($days +
$hours + $mins + $secs)"/>

  It looks to me like this is
rather complex to get such a timestamp.
Did I miss something?  Is there a way
to simplify this?  If not, and
because this is a kind of value (unfortunately)
still used in recents
API, it would probably be interesting to add a new
specifier for it in
the picture string format for fn:format-dateTime().

Florent Georges

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.