1
+ (:
2
+ : eXist-db Open Source Native XML Database
3
+ : Copyright (C) 2001 The eXist-db Authors
4
+ :
5
+
6
+ : http://www.exist-db.org
7
+ :
8
+ : This library is free software; you can redistribute it and/or
9
+ : modify it under the terms of the GNU Lesser General Public
10
+ : License as published by the Free Software Foundation; either
11
+ : version 2.1 of the License, or (at your option) any later version.
12
+ :
13
+ : This library is distributed in the hope that it will be useful,
14
+ : but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ : Lesser General Public License for more details.
17
+ :
18
+ : You should have received a copy of the GNU Lesser General Public
19
+ : License along with this library; if not, write to the Free Software
20
+ : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
+ :)
22
+ xquery version "3.0" ;
23
+
24
+ module namespace fd="http://exist-db.org/xquery/test/convert-dates" ;
25
+
26
+ declare namespace test="http://exist-db.org/xquery/xqsuite" ;
27
+
28
+ (: verify that we can convert xs:string to :xs:dateTimeStamp :)
29
+ declare
30
+ %test:args("2012-06-26T23:14:22.566+02:00" )
31
+ %test:assertEquals("11:14 pm on Tuesday, June 26th, 2012" )
32
+ function fd:format-dateTimeStamp ($date as xs:dateTimeStamp) {
33
+ format-dateTime ($date, "[h00]:[m00] [P] on [FNn], [MNn] [D1o], [Y]" , "en" , (), ())
34
+ };
35
+
36
+ (: verify that we can't convert xs:string without timezone to :xs:dateTimeStamp :)
37
+ declare
38
+ %test:args("2012-06-26T23:14:22.566" )
39
+ %test:assertError
40
+ function fd:convert-date-time-stamp ($date as xs:dateTimeStamp) {
41
+ format-dateTime ($date, "[h00]:[m00] [P] on [FNn], [MNn] [D1o], [Y]" , "en" , (), ())
42
+ };
43
+
44
+ (: verify that fn:current-dateTime() return type is xs:dateTimeStamp :)
45
+ declare
46
+ %test:assertEquals("true" )
47
+ function fd:current-dateTime-type () {
48
+ fn:current-dateTime () instance of xs:dateTimeStamp
49
+ };
0 commit comments