How create a date+time type of vbs in perl?
am 18.04.2011 10:49:54 von Xiao Yafeng
--===============0856076757==
Content-Type: multipart/alternative; boundary=bcaec51ba3fbe259c804a12d7a96
--bcaec51ba3fbe259c804a12d7a96
Content-Type: text/plain; charset=ISO-8859-1
Hi,
Is there a way to create a date type of vbs in perl?
for example,
how can I translate below vbs statement into perlish
one?
date_from = DateSerial(2011,03, 23) + timeserial(6, 0, 0)
any reply is really appreciated.
--bcaec51ba3fbe259c804a12d7a96
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi,=A0
=A0
Is there a way to create a date type of vbs=
in perl?
for example,
=A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 how can I translate below vbs statement int=
o perlish one?
=A0 =A0 =A0 =A0 =A0 =A0 =A0 date_from =3D DateSerial(2011,03, 2=
3) + timeserial(6, 0, 0)
any reply is really appre=
ciated.=A0
--bcaec51ba3fbe259c804a12d7a96--
--===============0856076757==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0856076757==--
RE: How create a date+time type of vbs in perl?
am 18.04.2011 12:13:39 von Eric Robertson
This is a multi-part message in MIME format.
--===============0941521555==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_003C_01CBFDB9.AB660C80"
This is a multi-part message in MIME format.
------=_NextPart_000_003C_01CBFDB9.AB660C80
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hi
Have you tried Date::Calc module, which I use for all my date and time calculations? It's pretty comprehensive.
Eric Robertson
_____
From: activeperl-bounces@listserv.ActiveState.com [mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of Xiao Yafeng
Sent: 18 April 2011 09:50
To: ActivePerl@listserv.ActiveState.com
Subject: How create a date+time type of vbs in perl?
Hi,
Is there a way to create a date type of vbs in perl?
for example,
how can I translate below vbs statement into perlish one?
date_from = DateSerial(2011,03, 23) + timeserial(6, 0, 0)
any reply is really appreciated.
------=_NextPart_000_003C_01CBFDB9.AB660C80
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
charset=3Dus-ascii">
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" =
name=3D"PersonName"/>
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Hi
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Have you tried Date::Calc module, =
which I
use for all my date and time calculations? It’s pretty =
comprehensive.
style=3D'font-size:
10.0pt;font-family:Arial'>
face=3DArial>
lang=3DEN-GB style=3D'font-size:10.0pt;font-family:Arial'>Eric =
Robertson
size=3D2 face=3DArial>
style=3D'font-size:10.0pt;font-family:Arial'>
>
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>
0cm 4.0pt'>
size=3D3
face=3D"Times New Roman">
style=3D'font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:
size=3D2
face=3DTahoma>
activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com]
style=3D'font-weight:
bold'>On Behalf Of Xiao Yafeng
Sent: 18 April 2011 =
09:50
To:
ActivePerl@listserv.ActiveState.com
Subject: How create a =
date+time
type of vbs in perl?
style=3D'font-size:
12.0pt'>
style=3D'font-size:
12.0pt'>Hi,
style=3D'font-size:
12.0pt'>
style=3D'font-size:
12.0pt'> Is there a way to create a date type of vbs in =
perl?
style=3D'font-size:
12.0pt'>
style=3D'font-size:
12.0pt'>for example,
style=3D'font-size:
12.0pt'> =
how can I translate below vbs statement into perlish =
one?
style=3D'font-size:
12.0pt'>
style=3D'font-size:
12.0pt'> =
date_from
=3D DateSerial(2011,03, 23) + timeserial(6, 0, =
0)
style=3D'font-size:
12.0pt'>
style=3D'font-size:
12.0pt'>any reply is really =
appreciated.
style=3D'font-size:
12.0pt'>
------=_NextPart_000_003C_01CBFDB9.AB660C80--
--===============0941521555==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0941521555==--
Re: How create a date+time type of vbs in perl?
am 19.04.2011 06:55:41 von Bill Luebkert
On 4/18/2011 1:49 AM, Xiao Yafeng wrote:
> Hi,
> Is there a way to create a date type of vbs in perl?
>
> for example,
> how can I translate below vbs statement into perlish one?
>
> date_from = DateSerial(2011,03, 23) + timeserial(6, 0, 0)
>
> any reply is really appreciated.
Windows has more than one time format, so it could get complicated if you
plan on doing anything wild with it.
file time is a dbl-word (64 bit) in 100-nanosecond intvls since Jan 1, 1601
system time is array of (YR, MON, DOW, HR, MIN, SEC, MSEC) similar to @tm
You also have to worry about where the time is from (local/UTC/etc).
What we don't know is what happens to date_from farther down to know
what to put in there - you would need to indicate that for a proper
response. The stuff below assumes you can modify that to use a @tm
structure to do what you need with it.
In your case, you only have human kinda times (year, month, day, hr, min, sec),
so it's a simple matter to plunk the data into a @tm structure and
do what you want with it. Just subtract 1900 from the year and 1
from the month and you're ready to go.
@tm = (, ,
, , , , , , ); # , []);
@tm = (0, 0, 6, 23, 2, 111, 0, 0, 0);
I sometimes add an extra 10th element where I store the TZO (timezone offset).
I compute DST and TZO to help convert from/to UTC/local.
# I'm in California, so I set my local TZ just in case:
$ENV{TZ} = 'PST8PDT' if not exists $ENV{TZ};
my $now = time; # current time (UTC)
my @ltm = localtime $now; # current local time @tm
my @gtm = gmtime $now; # current UTC time @tm
my $DST = $ltm[8]; # is daylight savings time ?
my $gnow = timegm (@gtm); # convert UTC @tm to epoch time
my $lnow = timegm (@ltm); # convert local @tm to epoch time
my $TZO = $lnow - $gnow; # diff in secs between UTC and local
# which can be converted to hrs/mins
you can convert it to epoch time for comparison/arithmetic
and then you have the usual formatting and conversion routines
gmtime/localtime/timegm/timelocal/strftime etc.
Your local @tm converted to epoch time using timelocal @tm => 1300885200;
Then you can use epoch time for calculations.
Then you could use the @tm structure to display your time:
my $TZ = $TZO / 3600; # convert TZO to hrs for display
print strftime ("%a, %d %b %Y %H:%M:%S $TZ\n", @tm[0..8]);
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs