Fellow monks,

I am hacking some Win32 OLE, and I'm having trouble formatting dates. Consider the following code (error checking omitted for clarity -- you may assume everything is working correctly):

my $value = $obj->method_call(); if( ref($value) eq 'Win32::OLE::Variant' and $value->Type == VT_DATE +) { return $value->Date( 'yyyy/MM/dd' ); } return $value;

This will return, e.g. were this the date of this node, '2001/09/03'. Unfortunately, my problem is that I can't coax it to print out the hours, minutes and seconds. I am certain that the dates in question have sub-day components because the native application can display them -- it's Lotus Notes if you really care.

Win32::OLE::Variant does define a number of boilerplate styles for formatting dates, such as DATE_LONGDATE, which would spit out Monday, September 03, 2001. For finer control, you can also build up format strings (as per my example) from such building blocks as

There is also a Time() for formatting Win32::OLE::Variant objects as times, and it offers various ways of specifying hours, minutes and seconds.

The really frustrating part is that you can't use Date()'s format specifiers in Time() and vice versa. That is, the following doesn't work:

my $datestamp = $value->Date( 'yyyy/MM/dd hh:mm:ss' );
(the 'hh:mm:ss' is passed through untouched).

In some ways this whole issue is moot, because what I would really like to do would be to convert the whole mess in epoch seconds and be done with it. That way the client code could format the date in a zillion different ways through other Perl modules (Date::Format springs to mind...).

But if I have little idea of how to format W::O::V dates, I have even less idea of how to get at the underlying representation to try and convert that to epoch time. Any clues I can use would be much appreciated.

--
g r i n d e r

In reply to Formatting Win32::OLE::Variant Dates by grinder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.