From 28b49143ea1dca9291a3e7d7fdf69657cdca2b65 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 5 Jun 2013 12:56:05 -0500 Subject: write_date_time requires the input to be in iso8601 form this is also much more readable as an intermediate form --- lib/Spreadsheet/Template/Generator/Parser/Excel.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib') diff --git a/lib/Spreadsheet/Template/Generator/Parser/Excel.pm b/lib/Spreadsheet/Template/Generator/Parser/Excel.pm index 97e6f01..812a6ed 100644 --- a/lib/Spreadsheet/Template/Generator/Parser/Excel.pm +++ b/lib/Spreadsheet/Template/Generator/Parser/Excel.pm @@ -1,6 +1,7 @@ package Spreadsheet::Template::Generator::Parser::Excel; use Moose::Role; +use DateTime::Format::Excel; use List::MoreUtils 'any'; with 'Spreadsheet::Template::Generator::Parser'; @@ -14,6 +15,13 @@ has excel => ( builder => '_build_excel', ); +has excel_dt => ( + is => 'ro', + isa => 'DateTime::Format::Excel', + lazy => 1, + default => sub { DateTime::Format::Excel->new }, +); + sub parse { my $self = shift; return $self->_parse_workbook; @@ -27,6 +35,10 @@ sub _parse_workbook { worksheets => [], }; + if ($self->excel->using_1904_date) { + $self->excel_dt->epoch_mac; + } + for my $sheet ($self->excel->worksheets) { push @{ $data->{worksheets} }, $self->_parse_worksheet($sheet); } @@ -92,6 +104,8 @@ sub _parse_cell { } elsif ($type eq 'Date') { $type = 'date_time'; + $contents = $self->excel_dt->parse_datetime($contents)->iso8601 + if defined $contents && length $contents; } else { die "unknown type $type"; -- cgit v1.2.3-54-g00ecf