Skip to content
Snippets Groups Projects
Unverified Commit 3396fffd authored by Benjamin W. Bohl's avatar Benjamin W. Bohl Committed by GitHub
Browse files

Merge pull request #7 from Edirom/issue-6

add tests for date:rfc822 and improve compliance, closes #6
parents 05786e17 7c839369
No related branches found
No related tags found
2 merge requests!2Merge1.4,!1WIP: 1.4.0
......@@ -35,4 +35,13 @@ declare
let $dateElement := <tei:date from="{$date1}" to="{$date2}"/>
return
date:getOneNormalizedDate($dateElement, $latest)
};
\ No newline at end of file
};
declare
%test:args("2002-10-02T15:00:00.040+02:00") %test:assertEquals("Wed, 02 Oct 2002 15:00:00 +0200")
%test:args("2004-02-29T23:00:00.98077-09:00") %test:assertEquals("Sun, 29 Feb 2004 23:00:00 -0900")
%test:args("1969-01-12T15:00:00") %test:assertEquals("Sun, 12 Jan 1969 15:00:00 +0000")
%test:args("1969-01-12T15:00:00Z") %test:assertEquals("Sun, 12 Jan 1969 15:00:00 +0000")
function dt:test-rfc822($dateTime as xs:dateTime) as xs:string {
date:rfc822($dateTime)
};
......@@ -251,10 +251,13 @@ declare function date:gregorian2julian($date as xs:date) as xs:date? {
declare function date:rfc822($dateTime as xs:dateTime) as xs:string {
let $year := year-from-date($dateTime)
let $month := substring(format-date($dateTime,'[MNn]'), 1, 3)
let $day := day-from-date($dateTime)
let $day := functx:pad-integer-to-length(day-from-date($dateTime), 2)
let $day.string := substring(format-date($dateTime,'[F]'), 1, 3)
let $time := format-time($dateTime,"[H]:[m]:[s]")
let $timezone := translate(format-date($dateTime, '[Z]'), ':', '')
let $timezone :=
if(exists(timezone-from-dateTime($dateTime)))
then translate(format-date($dateTime, '[Z]'), ':', '')
else '+0000'
return (
$day.string ||', '|| $day || ' ' || $month || ' ' || $year || ' ' || $time || ' ' || $timezone
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment