Skip to content

Commit

Permalink
RT#62916: Fixed dateTime.iso8601 stringification.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjray committed Jan 22, 2011
1 parent 4ef6b98 commit e787398
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/RPC/XML.pm
Expand Up @@ -61,7 +61,7 @@ BEGIN
RPC_DATETIME_ISO8601 RPC_BASE64 RPC_NIL) ],
all => [ @EXPORT_OK ]);

$VERSION = '1.51';
$VERSION = '1.52';
$VERSION = eval $VERSION; ## no critic (ProhibitStringyEval)

# Global error string
Expand Down Expand Up @@ -125,7 +125,7 @@ sub time2iso8601
my $zone = shift || q{};

my @time = gmtime $time;
$time = sprintf '%4d-%02d-%02dT%02d:%02d:%02dZ',
$time = sprintf '%4d%02d%02dT%02d:%02d:%02dZ',
$time[5] + 1900, $time[4] + 1, @time[3, 2, 1, 0];
if ($zone)
{
Expand Down Expand Up @@ -570,7 +570,7 @@ sub new
# given in the spec, so assume that other implementations can only
# accept this form. Also, this should match the form that time2iso8601
# produces.
$value = $7 ? "$1-$2-$3T$4:$5:$6$7" : "$1-$2-$3T$4:$5:$6";
$value = $7 ? "$1$2$3T$4:$5:$6$7" : "$1$2$3T$4:$5:$6";
if ($8)
{
$value .= $8;
Expand Down
8 changes: 7 additions & 1 deletion t/10_data.t
Expand Up @@ -5,7 +5,7 @@
use strict;
use vars qw($val $obj $class %val_tbl @values);

use Test::More tests => 198;
use Test::More tests => 200;
use RPC::XML ':all';

# First, the most basic data-types
Expand Down Expand Up @@ -121,6 +121,12 @@ $obj = RPC::XML::datetime_iso8601->new();
ok(! ref $obj, "RPC::XML::datetime_iso8601, bad value did not yield referent");
like($RPC::XML::ERROR, qr/::new: Malformed data.*passed/,
'RPC::XML::datetime_iso8601, bad value correctly set \$RPC::XML::ERROR');
# Test the slightly different date format
$obj = RPC::XML::datetime_iso8601->new('2008-09-29T12:00:00-07:00');
is($obj->type, 'dateTime.iso8601',
"RPC::XML::datetime_iso8601, type identification");
is($obj->value, '20080929T12:00:00-07:00',
'RPC::XML::datetime_iso8601, value() method test');

# Test the base64 type
require MIME::Base64;
Expand Down
2 changes: 1 addition & 1 deletion t/20_xml_parser.t
Expand Up @@ -81,7 +81,7 @@ SKIP: {
ok($args->[5]->value, 'RPC::XML::boolean value parsed OK');
isa_ok($args->[6], 'RPC::XML::datetime_iso8601',
'Parse of <dateTime.iso8601> argument');
is($args->[6]->value, '2008-09-29T12:00:00-07:00',
is($args->[6]->value, '20080929T12:00:00-07:00',
'RPC::XML::dateTime.iso8601 value parsed OK');
isa_ok($args->[7], 'RPC::XML::array', 'Parse of <array> argument');
is(scalar(@{$args->[7]->value}), 2, 'RPC::XML::array value parsed OK');
Expand Down
24 changes: 12 additions & 12 deletions t/21_xml_libxml.t
Expand Up @@ -7,17 +7,17 @@ use vars qw($p $req $res $ret $dir $vol $file);

BEGIN
{
use Test::More;

eval "use XML::LibXML";
if ($@)
{
plan skip_all => "XML::LibXML not installed";
}
else
{
plan tests => 40;
}
use Test::More;

eval "use XML::LibXML";
if ($@)
{
plan skip_all => "XML::LibXML not installed";
}
else
{
plan tests => 40;
}
}

require File::Spec;
Expand Down Expand Up @@ -95,7 +95,7 @@ SKIP: {
ok($args->[5]->value, 'RPC::XML::boolean value parsed OK');
isa_ok($args->[6], 'RPC::XML::datetime_iso8601',
'Parse of <dateTime.iso8601> argument');
is($args->[6]->value, '2008-09-29T12:00:00-07:00',
is($args->[6]->value, '20080929T12:00:00-07:00',
'RPC::XML::dateTime.iso8601 value parsed OK');
isa_ok($args->[7], 'RPC::XML::array', 'Parse of <array> argument');
is(scalar(@{$args->[7]->value}), 2, 'RPC::XML::array value parsed OK');
Expand Down

0 comments on commit e787398

Please sign in to comment.