Ah the subtleties of specs ! EPUB is asking for a specific sub-set of the allowed xs:dateTime formats What they are asking for is certainly "conformant" but not to be confused with "identical to"
And yes dateTime formatting is hell. functx has some good code for it as well. (which MarkLogic ships and supports) http://www.xqueryfunctions.com/xq/c0002.html#c0004 ----------------------------------------------------------------------------- David Lee Lead Engineer MarkLogic Corporation [email protected] Phone: +1 812-482-5224 Cell: +1 812-630-7622 www.marklogic.com<http://www.marklogic.com/> From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Saturday, May 11, 2013 7:10 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] return current dateTime in UTC format Well, the quote is from the O'Reilly book EPUB 3.0 Best Practices (p. 10). It references the the EPUB standard document at: http://www.idpf.org/epub/30/spec/epub30-publications.html That document states: -------------- To ensure that a Package Identifier can be constructed, the Publication must include exactly one [DCTERMS]<http://www.idpf.org/epub/30/spec/epub30-publications.html#refDCTERMS> modified property containing the last modification date (see meta<http://www.idpf.org/epub/30/spec/epub30-publications.html#elemdef-meta>). The value of this property must be an XML Schema [XSD-DATATYPES]<http://www.idpf.org/epub/30/spec/epub30-publications.html#refXSDDatatypes> dateTime conformant date of the form: CCYY-MM-DDThh:mm:ssZ The modification date must be expressed in Coordinated Universal Time (UTC) and must be terminated by the Z time zone indicator. <meta property="dcterms:modified">2011-01-01T12:00:00Z</meta> -------------- If curious, that is what got me going on this. Thanks again, Morgan ________________________________ From: "David Lee" <[email protected]> To: "MarkLogic Developer Discussion" <[email protected]> Sent: Saturday, May 11, 2013 6:24:18 PM Subject: Re: [MarkLogic Dev General] return current dateTime in UTC format Not sure where "billed elsewhere" is ... but the W3C spec is fairly clear (if complex) http://www.w3.org/TR/xmlschema-2/#dateTime The ·lexical space·<http://www.w3.org/TR/xmlschema-2/#dt-lexical-space> of dateTime consists of finite-length sequences of characters of the form: '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?, where That includes the possibility of fractional seconds and something other then Z for the timezone. ----- · '.' s+ (if present) represents the fractional seconds; · zzzzzz (if present) represents the timezone (as described below). For example, 2002-10-10T12:00:00-05:00 (noon on 10 October 2002, Central Daylight Savings Time as well as Eastern Standard Time in the U.S.) is 2002-10-10T17:00:00Z, five hours later than 2002-10-10T12:00:00Z. ----------------------------------------------------------------------------- David Lee Lead Engineer MarkLogic Corporation [email protected] Phone: +1 812-482-5224 Cell: +1 812-630-7622 www.marklogic.com<http://www.marklogic.com/> From: [email protected] [mailto:[email protected]] On Behalf Of [email protected] Sent: Saturday, May 11, 2013 6:17 PM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] return current dateTime in UTC format Ron (and David), Thanks. Yes, it "felt a bit wrong" to me too to have to slice and dice the dateTime as a string. I thought since this: 2013-05-11T17:01:18Z is billed elsewhere as "the standard W3C date and time format" that there was probably a built-in function for it. Morgan ________________________________ From: "Ron Hitchens" <[email protected]> To: "MarkLogic Developer Discussion" <[email protected]> Sent: Saturday, May 11, 2013 5:28:29 PM Subject: Re: [MarkLogic Dev General] return current dateTime in UTC format Try something like this (using XQuery 3.0 concatenation syntax): declare variable $orig-time := xs:dateTime ("2013-05-11T10:38:45.333548-04:00"); declare variable $utc-time := fn:adjust-dateTime-to-timezone ($orig-time, xs:dayTimeDuration('PT0H')); declare variable $adjusted-time := xs:dateTime (fn:substring (fn:string ($utc-time), 1, 19) || "Z"); $orig-time, $utc-time, $adjusted-time It feels a bit wrong to serialize an xs:dateTime to xs:string to truncate the fractional seconds. It would be better to be able to apply the fn:floor function to the seconds part. But there isn't an xs:dateTime constructor that takes the individual year, month, etc values, so you can only manipulate the string representation to make changes. --- Ron Hitchens {mailto:[email protected]} Ronsoft Technologies +44 7879 358 212 (voice) http://www.ronsoft.com +1 707 924 3878 (fax) Bit Twiddling At Its Finest "No amount of belief establishes any fact." -Unknown On May 11, 2013, at 6:41 PM, David Lee <[email protected]> wrote: > toss in an fn:replace() to strip off the fractional seconds, or you can use > format-dateTime() on the adjusted time, > but dont have it put a timezone on just concatentate the "Z" > or you can construct the string yourself by extracting out all the values and > concatenating them or > recreate a dateTime with no fractional seconds. > Lots of ways to skin the cat. > > > ----------------------------------------------------------------------------- > David Lee > Lead Engineer > MarkLogic Corporation > [email protected] > Phone: +1 812-482-5224 > Cell: +1 812-630-7622 > www.marklogic.com > > > From: [email protected] > [mailto:[email protected]] On Behalf Of > [email protected] > Sent: Saturday, May 11, 2013 1:07 PM > To: MarkLogic Developer Discussion > Subject: Re: [MarkLogic Dev General] return current dateTime in UTC format > > Ellis, > > Thanks, that's close. > > fn:adjust-dateTime-to-timezone(current-dateTime(),xs:dayTimeDuration('PT0H')) > > returns: > 2013-05-11T17:01:18.209498Z > > I need this: > 2013-05-11T17:01:18Z > > Morgan > > From: "Ellis Pritchard" <[email protected]> > To: "MarkLogic Developer Discussion" <[email protected]> > Sent: Saturday, May 11, 2013 12:21:06 PM > Subject: Re: [MarkLogic Dev General] return current dateTime in UTC format > > fn:adjust-dateTime-to-timezone($dateTime,xs:dayTimeDuration('PT0H')) > > Ellis. > > On 11 May 2013, at 15:52, [email protected] wrote: > > The current-dateTime() function returns the following: > > 2013-05-11T10:38:45.333548-04:00 > > I need to have it expressed in UTC (Coordinated Universal Time), with a > special UTC designator ("Z") like: > > 1994-11-05T13:15:30Z > > How is that done? With format-dateTime()? > > Thanks, > Morgan > _______________________________________________ > > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
