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

Reply via email to