Subject: | VT_ARRAY|VT_DATE Variant broken? |
Not that anyone ever needs a variant array of dates, but I noticed this
while testing something.
If my variant is of type VT_ARRAY|VT_DATE, Get always returns 12:00:00
AM (nil date) no matter what I try to Put.
Tested under a few permutations of ActivePerl builds 816/819, libwin32
0.24/0.26, Win32::OLE 0.1702/0.1704/0.1707, and Windows XP/2003.
Attaching test program, it runs through twice, first with a VT_DATE
array and then with a VT_BSTR array (just to assure myself I'm using
things right). It also tries variant-izing the date to be Put on each
but it doesn't make a difference. Sample outputs:
C:\projx>perl test_vardatearray.pl 11/12/2006
Win32 is v0.2601
Win32::OLE is v0.1704
(Using VT_DATE)
Date is '11/12/2006'
Element 0 is '12:00:00 AM'
Date is '11/12/2006'
Element 0 is '12:00:00 AM'
(Using VT_BSTR)
Date is '11/12/2006'
Element 0 is '11/12/2006'
Date is '11/12/2006'
Element 0 is '11/12/2006'
C:\projx>perl test_vardatearray.pl 4:30AM
Win32 is v0.2601
Win32::OLE is v0.1704
(Using VT_DATE)
Date is '4:30AM'
Element 0 is '12:00:00 AM'
Date is '4:30:00 AM'
Element 0 is '12:00:00 AM'
(Using VT_BSTR)
Date is '4:30AM'
Element 0 is '4:30AM'
Date is '4:30:00 AM'
Element 0 is '4:30:00 AM'
Subject: | test_vardatearray.pl |
use strict;
use warnings;
use Win32::OLE::Variant;
if (1) {
require Win32;
require Win32::OLE;
print "Win32 is v$Win32::VERSION\n";
print "Win32::OLE is v$Win32::OLE::VERSION\n";
print "\n";
}
for (qw/VT_DATE VT_BSTR/) {
my $type = $_;
print "(Using $type)\n";
$type = Win32::OLE::Variant->$type;
my $datearray = Variant($type|VT_ARRAY, 1);
my $date = "@ARGV"||"July 4, 2006";
print "Date is '$date'\n";
$datearray->Put(0, $date);
print "Element 0 is '".$datearray->Get(0)."'\n";
$date = Variant(VT_DATE, $date);
print "Date is '$date'\n";
$datearray->Put(0, $date);
print "Element 0 is '".$datearray->Get(0)."'\n";
print "\n";
}