<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Passing Full datetime through JSON in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287703#M240833</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to use ISO8601 format for all dates / datetimes. There are client side javascript functions to convert to / from this in Alfresco.util and server side ones as well. xmldate works with ISO8601.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bob Johnson&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 08 Jun 2013 09:14:51 GMT</pubDate>
    <dc:creator>rjohnson</dc:creator>
    <dc:date>2013-06-08T09:14:51Z</dc:date>
    <item>
      <title>Passing Full datetime through JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287702#M240832</link>
      <description>I'm passing the created and modified metadata for documents via JSON from the repo to share. I found that I can't pass the raw format through JSON so I formatted it as dd MMM yyyy HH:mm:ss a '('zzz')'The problem I'm seeing is I can process this with xmldate or datetime because I'm including the time</description>
      <pubDate>Sat, 08 Jun 2013 00:11:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287702#M240832</guid>
      <dc:creator>ashex</dc:creator>
      <dc:date>2013-06-08T00:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Full datetime through JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287703#M240833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to use ISO8601 format for all dates / datetimes. There are client side javascript functions to convert to / from this in Alfresco.util and server side ones as well. xmldate works with ISO8601.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bob Johnson&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Jun 2013 09:14:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287703#M240833</guid>
      <dc:creator>rjohnson</dc:creator>
      <dc:date>2013-06-08T09:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Full datetime through JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287704#M240834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To return the full date and time information I'll need to reformat it before presenting it through JSON then? Will xmldate preserve everything and be valid for JSON consumption?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jun 2013 17:49:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287704#M240834</guid>
      <dc:creator>ashex</dc:creator>
      <dc:date>2013-06-10T17:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Full datetime through JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287705#M240835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Basically yes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are a couple of ways of doing this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are returning a date from a repository webscript you can either convert the date in the javascript .get.js file or do it in the .json.ftl.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Doing it in javascript you would do something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;result['issuedOnAt'] = utils.toISO8601(relatedItem.properties["fgitem:issuedOnAt"]);&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and then you don't need to bother with xmldate in the ftl because the date is already formatted correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alternatively you can simply pass the document properties into the ftl template, optionally define a macro (just for ease of use) and convert the date format there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;lt;#macro dateFormat date&amp;gt;${xmldate(date)}&amp;lt;/#macro&amp;gt;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Goes at the top of your ftl template and then you can do&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;"modifiedOn": "&amp;lt;@dateFormat item.properties.modified /&amp;gt;",&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To produce a correctly formatted ISO8601 date.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the client side you have&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;var myDate = Alfresco.util.fromISO8601(jsonobject.datenode);&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;var my8601Date = Alfresco.util.toISO8601(javascript_date_object);&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;which convert dates either way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bob Johnson&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jun 2013 09:35:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287705#M240835</guid>
      <dc:creator>rjohnson</dc:creator>
      <dc:date>2013-06-11T09:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Full datetime through JSON</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287706#M240836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the info, that will be super useful. I had tried using xmldate with the JSON template but it kept throwing an error. I'll take another look at it with the methods you've recommended.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jun 2013 23:29:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/passing-full-datetime-through-json/m-p/287706#M240836</guid>
      <dc:creator>ashex</dc:creator>
      <dc:date>2013-06-12T23:29:33Z</dc:date>
    </item>
  </channel>
</rss>

