Search code examples
schematron

How to add +8 hrs in current-dateTime() for date functions in schematron/xslt.


I am working on schematron Validations, in that validation I have one rule in which is Date should not be greater than current date. rule is fine but my problem is I validate the Date as per PST and client having GMT timestamp for date, there is 8 hrs difference so please help how to add +8 hrs in validation rule of schematron, if there is having some mechanisum to compare those timestamps then please answer in comment. thanks to all in adv.

Thanks, Manoj


Solution

  • The XPath date functions respects the timezone, if it is known. So it depends on, how you write your date into the file.

    If you write it in this format:

    <date>2016-06-23T11:30:34.000-10:00</date>
    

    the timezone should be respected.

    If this is not possible, you can add the 8hrs manually:

    current-dateTime() + xs:dayTimeDuration('PT08H')
    

    [Edit:] see the declaration of xs:dayTimeDuration

    In this cases you may need a new namespace declaration for the xs prefix:

    <sch:ns uri="http://www.w3.org/2001/XMLSchema" prefix="xs"/>