File: 01-util.t

package info (click to toggle)
libxml-atom-perl 0.09-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 288 kB
  • ctags: 223
  • sloc: perl: 2,423; xml: 235; makefile: 50
file content (35 lines) | stat: -rw-r--r-- 1,013 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# $Id: 01-util.t,v 1.4 2003/09/28 21:12:32 btrott Exp $

use strict;

use Test;
use XML::Atom::Util qw( iso2dt );

BEGIN {
    unless (eval { require DateTime; }) {
        print "1..0\n";
        exit;
    }
    plan tests => 12;
}

my %tests = (
    '20030928' => '2003-09-28T00:00:00',
    '2003-09-28' => '2003-09-28T00:00:00',
    '2003-09-28T12:49:50' => '2003-09-28T12:49:50',
    '2003-09-28T12:49:50Z' => '2003-09-28T12:49:50',
    '2003-09-28T12:49:50-00:00' => '2003-09-28T12:49:50',
    '2003-09-28T12:49:50+00:00' => '2003-09-28T12:49:50',
    '2003-09-28T12:49:50-01:00' => '2003-09-28T13:49:50',
    '2003-09-28T12:49:50+01:00' => '2003-09-28T11:49:50',
    '2003-09-28T12:49:50-01:30' => '2003-09-28T14:19:50',
    '2003-09-28T12:49:50+01:30' => '2003-09-28T11:19:50',
    '2003-09-28T12:49:50+17:00' => '2003-09-27T19:49:50',
    '2003-09-28T12:49:50-17:00' => '2003-09-29T05:49:50',
);

for my $test (keys %tests) {
    ok(iso2ts($test), $tests{$test});
}

sub iso2ts { iso2dt($_[0])->iso8601 }