Win32::RemoteTOD - Get the time & timezone of a remote Win32 machine
use strict; use Win32::RemoteTOD qw(GetTOD); my $TimeInfo; my $Result = GetTOD('servername', $TimeInfo); if ($Result) { print "Error: $Result\n"; exit 1; } my @days = qw( Sunday Monday Tuesday Wednesday Thursday Friday Saturday ); printf("Date/Time is %s %02u/%02u/%02u %02u:%02u:%02u.%02u GMT.\n", $days[$TimeInfo->{weekday}], $TimeInfo->{month}, $TimeInfo->{day}, $TimeInfo->{year}, $TimeInfo->{hours}, $TimeInfo->{mins}, $TimeInfo->{secs}, $TimeInfo->{hunds}, ); if ($TimeInfo->{timezone} == -1) { print "The timezone is undefined.\n"; } elsif ($TimeInfo->{timezone} == 0) { print "The timezone is GMT.\n"; } else { printf("The timezone is %u minutes %s of GMT.\n", abs($TimeInfo->{timezone}), $TimeInfo->{timezone} > 0 ? 'west' : 'east', ); }
Win32::RemoteTOD is used to retreive the date, time, and timezone from a remote Win32 machine. There is one function, called "GetTOD()" which sets a hashref containing 12 keys as follows (direct from MSDN):
Specifies a DWORD value that contains the number of seconds since 00:00:00, January 1, 1970, GMT.
Specifies a DWORD value that contains the number of milliseconds from an arbitrary starting point (system reset). Typically, this member is read twice, once when the process begins and again at the end. To determine the elapsed time between the process's start and finish, you can subtract the first value from the second.
Specifies a DWORD value that contains the current hour. Valid values are 0 through 23.
Specifies a DWORD value that contains the current minute. Valid values are 0 through 59.
Specifies a DWORD value that contains the current second. Valid values are 0 through 59.
Specifies a DWORD value that contains the current hundredth second (1.00 second). Valid values are 0 through 99.
Specifies the time zone of the server. This value is calculated, in minutes, from Greenwich Mean Time (GMT). For time zones west of Greenwich, the value is positive; for time zones east of Greenwich, the value is negative. A value of -1 indicates that the time zone is undefined.
Specifies a DWORD value that contains the time interval for each tick of the clock. Each integral integer represents one ten-thousandth second (0.0001 second).
Specifies a DWORD value that contains the day of the month. Valid values are 1 through 31.
Specifies a DWORD value that contains the month of the year. Valid values are 1 through 12.
Specifies a DWORD value that contains the year.
Specifies a DWORD value that contains the day of the week. Valid values are 0 through 6, where 0 is Sunday, 1 is Monday, and so on.
The single function, GetTOD() is exported by default.
Adam Rich, <arich@cpan.org>
perl.
To install Win32::RemoteTOD, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Win32::RemoteTOD
CPAN shell
perl -MCPAN -e shell install Win32::RemoteTOD
For more information on module installation, please visit the detailed CPAN module installation guide.