Problem when calling .dll from visual studio created as COM control that uses DateTime packages

Posted by leonardomadrigal on 2011-07-22 08:06
Forums: PDK Support | OS: Windows 7

When I execute my routine from console everything works fine:

> perl 0
> 2011-05-22T10:37:38

In the code I call to:

$soap_datetime = SOAP::DateTime::ConvertDate($t);

As you can see this actually works directly with perl, but when I create the
control with perlctrl and try to call the subroutine that calls

$soap_datetime = SOAP::DateTime::ConvertDate($t);

I get an error:

Undefined subroutine &SOAP::DateTime::ParseDate called at code.dll

When trying to call a subroutine that use SOAP::DateTime::ConvertDate

going inside ConvertDate:

sub ConvertDate {
        my $date = shift;
        die "No date supplied\n" unless $date;
        my $parsed = Time::ParseDate::parsedate($date);
        die "Unparseable date\n" unless $parsed;

I've also tried this:

This works with perl, but not when created the dll and trying to use the method from Visual studio 2010 or Express 2008

use DateTime;
use DateTime::TimeZone;
use DateTime::Format::MySQL;

sub ConvertDate {
        my $TIMESTART = shift;
        $TIMESTART =~ s/Z//;
        $TIMESTART =~ s/T/ /g;
        $TIMESTART =~ s/.[0-9][0-9][0-9]$//g;

        my $dt = DateTime::Format::MySQL->parse_datetime($TIMESTART);
        $dt->set_time_zone('UTC'); ## set timezone of parsed date time
        $dt->set_time_zone('Mexico/General'); ## change timezone in safe way

        print DateTime::Format::MySQL->format_datetime($dt),"\n"; ## check the result

Same error:

Can't locate object method "parse_datetime" via package "DateTime::Format::MySQL" (perhaps you forgot to load "DateTime::Format::MySQL"?) at line 138.

Not sure why perlctrl is not working...

I've tried to use this subroutine directly in my code and I got error when trying to call
UnixDate (This works directly with perl, but not in the control)

I've also tried to add modules: Date::Manip::** as it is the package SOAP::DateTime uses...