I've used vbconverter to translate now function into perl:

package VBS;
use strict;

use Win32::OLE::NLS qw(:TIME
       :DATE
       GetLocaleInfo GetUserDefaultLCID
                       LOCALE_SMONTHNAME1 LOCALE_SABBREVMONTHNAME1
                       LOCALE_SDAYNAME1 LOCALE_SABBREVDAYNAME1
       LOCALE_IFIRSTDAYOFWEEK
       LOCALE_SDATE LOCALE_IDATE
       LOCALE_SGROUPING
       );
use Win32::OLE::Variant;

use constant EPOCH       => 25569;
use constant SEC_PER_DAY => 86400;

our $lcid;
BEGIN {
    $lcid = GetUserDefaultLCID();
    Win32::OLE->Option(LCID => $lcid);
}

# Return the local time in seconds since the epoch.
sub _localtime_in_sec {
    require Time::Local;
    return 2.0 * CORE::time() - Time::Local::timelocal(gmtime);
}

# Extract specific information out of a date.
sub _extract_from_date {
    my($date,$method,$format) = @_;
    return unless $date;
    unless (UNIVERSAL::isa($date, "Win32::OLE::Variant")) {
        $date = Variant(VT_DATE, $date);
    }
    return $date->$method($format, $lcid);
}

# Returns the current date and time according to the setting of your
# computer's system date and time.
sub Now {
    return Variant(VT_DATE, EPOCH + _localtime_in_sec()/SEC_PER_DAY);
}

As above code, VB's time format is just dates wrapped by VT_DATE. Is it
right?
And, What is lcid? What is the usage of redundant package ( Win32::OLE::NLS
) and function ( _extract_from_date) ?



On Sun, Sep 19, 2010 at 10:54 PM, John Mason Jr <[email protected]>wrote:

>   On 9/19/2010 7:48 AM, Ludwig, Michael wrote:
> >>     Could you tell me how create a time object of VBS in perl? Below
> >> statement define a starting time and pass it to the getdata function
> >> to get data in VBS:
> >>
> >> start_time = DateSerial( 2003, 01, 31) + TimeSerial( 6, 0, 0)
> >> data_array = lpd.getdata(id, start_time)
> >>
> >> But I don't know how to translate it into perl.
> >> Since I intend to rewrite all vbs scripts, it will be a big problem!
> > Using Windows Script Files (.wsf)
> > http://msdn.microsoft.com/en-us/library/15x4407c%28VS.85%29.aspx
> >
> > WSF might be helpful to you. It allows you to have several engines
> > work jointly. You might be able to keep the parts in VBS that are not
> > practical to port to Perl. It is XML, so you can use Unicode in your
> > script.
> >
>
> If you are doing a bunch of conversions then you might want to look at
> the Perl Dev Kit as it has a vbscript to perl converter
>
> John
> _______________________________________________
> ActivePerl mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to