I was inspired to use Mojo::XMLRPC
after reading The Mojolicious Blog - Day 11. I'm having problems with Mojo::Date
format.
During encode_xmlrpc
, <dateTime.iso8601>
is 2023-06-14T19:45:48Z
. Instead, I need it as: 20230614T22:45:48+0300
During decode_xmlrpc
, I get an error when <dateTime.iso8601>
is 20230608T12:00:00+0000
:
Garbage at end of string in strptime: +0000 at /usr/local/opt/perl/lib/perl5/5.36/darwin-thread-multi-2level/Time/Piece.pm line 598.
Perhaps a format flag did not match the actual input? at /usr/local/opt/perl/lib/perl5/5.36/darwin-thread-multi-2level/Time/Piece.pm line 598.
EDIT: I believe a missing '%H:%M:%S%z'
at the front of $time_format
array in XMLRPC.pm
is my issue (?)
How can I instruct Mojo::XMLRPC
(or Mojo::Date
?) to use the desired DateTime format?
Sample code below:
#!/usr/bin/env perl
use Mojo::XMLRPC qw[encode_xmlrpc decode_xmlrpc];
use Data::Dumper;
my $e = encode_xmlrpc(call => TaregtMethod => {originTimeStamp=>Mojo::Date->new(time)});
say STDERR Dumper($e);
my $xml = <<'XML';
<?xml version="1.0" encoding="utf-8"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>activationDate</name>
<value>
<dateTime.iso8601>20230608T12:00:00+0000</dateTime.iso8601>
</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>
XML
my $d = decode_xmlrpc($xml);
say STDERR Dumper($d);
The problem is at the other end.
During
encode_xmlrpc
,<dateTime.iso8601>
is2023-06-14T19:45:48Z
. Instead, I need it as:20230614T22:45:48+0300
It's not configurable, and that's not a valid iso8601 serialization.
During
decode_xmlrpc
, I get an error when<dateTime.iso8601>
is20230608T12:00:00+0000
:
That's to be expected since the string isn't a valid iso8601 serialization.
Valid iso8601 formats can be found in the documentation for DateTime::Format::ISO8601.
Mojo::XMLRPC doesn't accept all of them, and it accepts many other formats that aren't part of iso8601.