default date/time

carballo's Avatar

carballo

22 Jun, 2010 04:51 PM

Is there a way to include "today" and/or "now" as "default" for data definition's calendar and date-time fields?

If not, am I correct in assuming that the approach to take is to use the "last-modified" metadata field that uses unix time (and for which there is not an easy way to convert using XSLT 1.0)?

Thanks

Erick

  1. 1 Posted by Penny on 22 Jun, 2010 07:38 PM

    Penny's Avatar

    I do not believe there is currently a way to default the field in the Data Definition. I would make it a mandatory field and rely on users to fill it in correctly.

    I would generally suggest using the datetime type over the calendar type in the Data Definition because it produces the Unix number that makes sorting easier in my opinion.

    If you go this route or need to format Unix timestamps in the future, there should be an included Format Date function in Cascade in the common site that you should be able to pretty easily reuse. If you started on a later version of Cascade go to the common site and check for the following format, /formats/include/format-date. You should be able to include it in your XSLT where ever you need a date formatted by using the following line above all of your xsl:template matches: <xsl:include href="site://_common/formats/include/format-date"/>

    You can then just call the format date function using the last-modified date as one param and the appropriate formatting mask for the other param. There is pretty good documentation in the format-date xslt that explains how to use it.

    Please let me know if you do not have this format in your instance or if you have any further issues with this.

  2. 2 Posted by carballo on 22 Jun, 2010 07:55 PM

    carballo's Avatar

    Penny, thanks for your input.

    We were aware of the /formats/include/format-date file, unfortunately we need this in the Global area. Furthermore, when we updated from an earlier version of cascade to 6.x the update kept all the common folder materials (under the Default area), but did not add any of the common site materials.

    Does anyone know?:

    1- if the format-date file only works for sites or if it can be used in the global area
    2- if it works under Global, could someone post it here so I can then include it

    Thanks

    Erick

  3. 3 Posted by Penny on 22 Jun, 2010 08:05 PM

    Penny's Avatar

    It works inside of sites and inside global. It is just an XSLT file that you include inside another XSLT, no real site implications. If you put it in your global region, you just won't need to have the "site://_common" in your href to it.

    Here is a link to it in our code sharing site: Format Date in Github

    I would just copy the contents and create the format in your global area.

    Please let me know if you need any further direction.

  4. 4 Posted by carballo on 22 Jun, 2010 08:12 PM

    carballo's Avatar

    Thank-you!

    E~

  5. Tim closed this discussion on 22 Jun, 2010 09:28 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac