如何在xforms中使用adjust-dateTime-to-timezone函数?

时间:2012-07-17 13:56:12

标签: datetime xforms

我们在表单中有一个特殊功能,它应该将日期和时间值转换为用户的本地时区。 我了解到在xfdl版本8中已经有adjust-dateTime-to-timezone()日期函数,所以我尝试使用它。

然而,我一直收到错误 Tue Jul 17 21:49:28 2012 0查看器:xforms-compute-exception:adjust-dateTime-to-timezone(../ utcDT)。

这是实际的源代码。

<XFDL xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom" xmlns:designer="http://www.ibm.com/xmlns/prod/workplace/forms/designer/2.6" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/8.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns="http://www.ibm.com/xmlns/prod/XFDL/8.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<globalpage sid="global">
    <global sid="global">
        <designer:date>20120717</designer:date>
        <formid>
            <title/>
            <serialnumber></serialnumber>
            <version>1.0.0</version>
        </formid>
        <pageloading>
            <ondemand>enable</ondemand>
        </pageloading>
        <transmitformat>application/vnd.xfdl;content-encoding=base64-gzip</transmitformat>
        <saveformat>application/vnd.xfdl;content-encoding=base64-gzip</saveformat>
        <xformsmodels>
            <xforms:model>
                <xforms:instance id="formData" xmlns="">
                    <root>
                        <utcDT>2011-09-01T23:00:01Z</utcDT>
                        <!-- UTC dateTime -->
                        <localDT>2011-09-01T23:00:01Z</localDT>
                        <!-- local dateTime with the timezone (accounting for daylight saving correction) -->
                    </root>
                </xforms:instance>
                <xforms:bind nodeset="utcDT | localDT" type="xforms:dataTime"/>
                <xforms:bind calculate="adjust-dateTime-to-timezone(../utcDT)" nodeset="localDT"/>
            </xforms:model>
        </xformsmodels>
        <history>
            <editors>
                <editor minversion="3.5.1" version="4.0.0">IBM Forms Designer</editor>
            </editors>
        </history>
    </global>
</globalpage>
<page sid="PAGE1">
    <global sid="global">
        <label>PAGE1</label>
    </global>
    <label sid="l2">
                <xforms:output ref="localDT">
                    <xforms:label>Local dateTime = </xforms:label>
                </xforms:output>
    </label>
    <spacer sid="vfd_spacer">
        <itemlocation>
            <x>960</x>
            <y>1260</y>
            <width>1</width>
            <height>1</height>
        </itemlocation>
    </spacer>
</page>

非常感谢您的帮助!提前谢谢!

从 凯利

1 个答案:

答案 0 :(得分:1)

adjust-dateTime-to-timezone的第一个参数必须是xs:dateTime,你在这里传递一个元素。所以相反,你会写:

adjust-dateTime-to-timezone(xs:dateTime(../utcDT))