*** /usr/lib/perl5/vendor_perl/5.8.8/DateTime/Format/W3CDTF.pm	2007-03-25 22:24:08.000000000 +0100
--- /home/waider/src/perl/W3CDTF.pm	2007-05-21 00:19:40.000000000 +0100
***************
*** 5,11 ****
  
  use vars qw ($VERSION);
  
! $VERSION = '0.04';
  
  use DateTime;
  
--- 5,11 ----
  
  use vars qw ($VERSION);
  
! $VERSION = '0.05';
  
  use DateTime;
  
***************
*** 54,83 ****
  {
      my ( $self, $date ) = @_;
  
!     # save for error messages
!     my $original = $date;
  
! 	my %p;
!     if ( $date =~ s/([+-]\d\d:\d\d)$// )
!     {
!         $p{time_zone} = $1;
!     }
!     # Z at end means UTC
!     elsif ( $date =~ s/Z$// )
!     {
!         $p{time_zone} = 'UTC';
!     }
!     else
!     {
!         $p{time_zone} = 'floating';
!     }
  
!     my $format = $valid_formats{ length $date }
!         or confess "Invalid W3CDTF datetime string ($original)";
  
!     @p{ @{ $format->{params} } } = $date =~ /$format->{regex}/;
  
!     return DateTime->new( %p, %{ $format->{zero} } );
  }
  
  sub format_datetime
--- 54,92 ----
  {
      my ( $self, $date ) = @_;
  
!     my %parsed;
!     my @bits = $date =~
!       /^(\d\d\d\d)(-(\d\d)(-(\d\d)(T(\d\d:\d\d(:\d\d(\.\d+)?)?(Z|[-+]\d\d:\d\d))?)?)?)?$/;
! 
!     confess "Invalid W3CDTF datetime string $date" unless @bits;
!     # if the regexp didn't match, the format is invalid.
! 
!     $parsed{year} = $bits[0] if $bits[0];
!     $parsed{month} = $bits[2] if $bits[2];
!     $parsed{day} = $bits[4] if $bits[4];
!     $parsed{time} = $bits[6] if $bits[6];
! 
!     # now split up the time
!     if ( defined( $parsed{time})) {
!         @bits = $parsed{time} =~ /^(\d\d):(\d\d)(.*)(Z|[-+]\d\d:\d\d)$/;
!         $parsed{hour} = $bits[0];
!         $parsed{minute} = $bits[1];
!         $parsed{second} = $bits[2];
!         $parsed{time_zone} = $bits[3];
  
!         $parsed{second} ||= 0;
!         $parsed{second} =~ s/^://;
  
!         # since DateTime doesn't support fractional seconds:
!         $parsed{second} =~ s/\.\d+$//;
! 
!         delete $parsed{time};
!     }
  
!     # cribbed from original
!     $parsed{time_zone} ||= 'floating';
  
!     return DateTime->new( %parsed );
  }
  
  sub format_datetime

