Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ankita 42 posts 62 karma points
    Aug 30, 2012 @ 10:29
    Ankita
    0

    Parsing Error In umbraco.library.DateGreaterThanOrEqual(String firstDate, String secondDate)

    I get error when comare tow dates using function  DateGreaterThanOrEqual(String firstDate, String secondDate)

    when I compare using current date its working properly, but when I compare current date with datepicter date , It gives error

     my code is:-

    <xsl:variable name="node" select="$currentPage/ancestor-or-self::node/descendant-or-self::node[@nodeTypeAlias = 'Test1']" />
    <xsl:variable name="fdate" select="$node/data[@alias='CompEnd']"/>
    <xsl:variable name="sdate" select="umbraco.library:CurrentDate()"/>
       <xsl:value-of select="umbraco.library:DateGreaterThanOrEqual( $fdate, $sdate)" disable-output-escaping="yes"/>

    Error occured

    System.FormatException: String was not recognized as a valid DateTime. 
    at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) 
    at umbraco.library.DateGreaterThanOrEqual(String firstDate, String secondDate)

    Thanks,

     

     

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Aug 30, 2012 @ 11:06
    Lee Kelleher
    0

    Hi Ankita,

    Is it possible that "$node/data[@alias='CompEnd']" doesn't contain a date?  Try outputting it to see what's in there.

    <xsl:value-of select="$fdate" />

    Cheers, Lee.

  • Ankita 42 posts 62 karma points
    Aug 30, 2012 @ 15:48
    Ankita
    0

    Hi Lee,

    I have checked the value that comes from 

     

    <xsl:value-of select="$fdate"/>

    <br/>

    <xsl:value-of select="$sdate"/>

    is in format

    2012-08-13T02:32:00
    2012-08-30T08:43:50

    But when we compare currentdate this does not give any error , It works properly.

     

     

  • Ankita 42 posts 62 karma points
    Aug 31, 2012 @ 10:41
    Ankita
    0

    Is there anyone who can solve my problem.

    why function  DateGreaterThanOrEqual(String firstDate, String secondDate) not get my datepicker value, besides it is not giving error when used  "sdate" variable

    <xsl:variable name="sdate" select="umbraco.library:CurrentDate()"/>

    In sdate it get current date 

     I have checked the value that comes from my datapicker property and current date is:-

    <xsl:value-of select="$datepicker"/> <xsl:value-of select="$currentdate"/>

    is in format

    2012-08-13T02:32:00
    2012-08-30T08:43:50

    Please tell me what's a silly mistake that I am doing .

    Please help me ,I got stuck by this error

    Any reply would be appreciable,

    thanks in advance

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Sep 01, 2012 @ 16:48
    Chriztian Steinmeier
    0

    Hi Ankita,

    How many documents of the type Test1 do you have in the site?

    The thing is that $fdate actually a nodeset of all the CompEnd properties of all Test1 documents in the Umbraco solution - so that might be the problem (because a nodeset is sent to the function).

    The reason you get a seemingly valid value with value-of, is because the value-of instruction will only output the first node, if passed a nodeset.

    So I think you need to specify the exact node you want to do the comparison with...

    /Chriztian

  • Ankita 42 posts 62 karma points
    Sep 02, 2012 @ 21:04
    Ankita
    0

    Hi Chriztian,

    I have used only one time "Test1" document type in my hierarchy. So in that case there is only one property named "CompEnd" in hierarchy. I am still stuck by this problem. So if you have any other solution/idea/suggestion regarding this problem, Please reply ASAP.  

    thanks,

    Bhuvneshwari.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Sep 02, 2012 @ 21:19
    Chriztian Steinmeier
    0

    Okay,

    Tricky stuff - could you try the DateGreaterThanOrEqualToday(String date) function? Just to see if that throws errors as well?

    I'm curious if this could be Locale related somehow... which language is the machine set to? Have you assigned a hostname and language to the tree containing the CompEnd property?

    /Chriztian

  • Ankita 42 posts 62 karma points
    Sep 03, 2012 @ 06:46
    Ankita
    0

    Hi Chriztian,

    I have used DateGreaterThanOrEqualToday(String date) function and passed "CompEnd" property value to it, but it throws the same error. Don't know what's happen with it? Do you know solution of this type error? Yes I have assigned hostname and language to the tree.

    Thanks for your reply

     

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Sep 03, 2012 @ 07:54
    Chriztian Steinmeier
    0

    Which language have you set?

    Could you post the entire XSLT file? (Or if it's large, put it on http://gist.github.com and link to it).

    /Chriztian

  • Ankita 42 posts 62 karma points
    Sep 03, 2012 @ 08:03
    Ankita
    0

    Here is my Xslt file:-

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
        version="1.0"
            xmlns:datetime="http://exslt.org/dates-and-times"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
        xmlns:myfunctionlib="urn:myfunctionlib"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
        exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.library myfunctionlib ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>


    <xsl:template match="/">



    <xsl:variable name="node" select="$currentPage/ancestor-or-self::node/descendant-or-self::node[@nodeTypeAlias = 'Test1']" />
    <xsl:variable name="fdate" select="$node/data[@alias='CompEnd']"/>
    <xsl:variable name="sdate" select="umbraco.library:CurrentDate()"/>
      <!-- 
    <xsl:value-of select="umbraco.library:DateGreaterThanOrEqual( $sdate, $fdate)"/>
    <xsl:value-of select="$fdate"/><br/>
    <xsl:value-of select="$sdate"/>

     <xsl:value-of select="umbraco.library:FormatDateTime($node/data[@alias='CompEnd'], 'ddd, dd MMM yyyy hh:mm:ss')"/>
    <br/>
     <xsl:value-of select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(), 'ddd, dd MMM yyyy hh:mm:ss')"/>
    <br/>
    <xsl:value-of select="Exslt.ExsltDatesAndTimes:formatdate( $fdate, 'g')"/>
    <br/>
    <xsl:value-of select="Exslt.ExsltDatesAndTimes:formatdate( $sdate, 'g')"/>

    <xsl:value-of select="umbraco.library:DateGreaterThanOrEqual($b2, $b1)"/>
    -->


    <xsl:variable name="b1" select="umbraco.library:FormatDateTime($node/data[@alias='CompEnd'], 'ddd, dd MMM yyyy hh:mm:ss')"/>
    <xsl:variable name="b2" select="umbraco.library:FormatDateTime(umbraco.library:CurrentDate(), 'ddd, dd MMM yyyy hh:mm:ss')"/>

    <xsl:choose>
    <xsl:when test="$sdate &lt;= $fdate">
    <xsl:if test="$sdate &lt;= $fdate">
    <div class="comp_end">
    <xsl:variable name="node1" select="$currentPage/ancestor-or-self::node/descendant-or-self::node[@nodeTypeAlias = 'ContestEnd'] "/>
    <div class="comp_question"><xsl:value-of select="$node1/data[@alias = 'EndContestTitle']"  disable-output-escaping="yes" /></div>

    </div> <!-- End comp_end -->

    </xsl:if>
    </xsl:when>
    <xsl:otherwise>

    <div style="comp_start">
    <xsl:variable name="node2" select="$currentPage/ancestor::node[@nodeTypeAlias = 'test']" />

    <div class="comp_cta"><a href="#">Enter Competition Here</a></div>

    </div> <!-- End comp_start -->

    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>


    </xsl:stylesheet>

     

  • Arne 10 posts 30 karma points
    Oct 15, 2012 @ 10:00
    Arne
    0
    I experienced the same problem. Got an error message when I compared datepicer date and todays date. I just check the "Skip testing (ignore errors)" in the xsl editor and saved the file, and it worked on the site.
    By checking if the datepicer date is blank or not it works, no error message in the xsl editor.
Please Sign in or register to post replies

Write your reply to:

Draft