3.2. datetime

3.2.1. NAME

datetime - Guardian Digital WebTool module interface to the system date and time.

3.2.2. SYNOPSIS

use datetime;
my $time  = new datetime;

3.2.3. DESCRIPTION

This Guardian Digital WebTool module provides an interface to manipulating the system date and time. This module allows you to manage the system NTP servers, set the system locale/timezone, and set the system date and time.

3.2.4. METHODS

new()

This contructor instantiates a new datetime object, which contains the NTP configuration and the zone configuration.

Example Usage:

my $time      = new datetime;

my $ntp1      = $time->{'ntp_config'}->{'server'}->[0];
my $ntp2      = $time->{'ntp_config'}->{'server'}->[1];
my $ntp3      = $time->{'ntp_config'}->{'server'}->[2];
my $region    = $time->{'zone_config'}->{'region'}
my $area      = $time->{'zone_config'}->{'area'}

restart_ntpd()

This function is used to restart NTP daemon if and only if its running.

Example Usage:

$time->restart_ntpd();

enumerate_ntp_servers()

This function can be used to get all listed ntp servers. It returns array of servers.

Example Usage:

@servers = $time->enumerate_ntp_servers();

enumerate_zoneinfo()

This function serves purpose of getting all zone and area information by reading directory tree /usr/share/zoneinfo. It makes a hash containing zones as keys and areas as their values and returns a reference.

Example Usage:

$zones = $time->enumerate_zoneinfo();

set_ntp_servers($$$)

This function is used to set all three ntp servers in configuration file. It receives three server names as argument, then it updates /etc/ntp/ntp.conf. It also writes all server names in /etc/ntp/step-tickers too.

Example Usage:

$time->set_ntp_servers($server1, $server2, $server3);

set_system_time($)

This function sets the system time according to given argument. Hash reference containing values of month,day,year,hour,minute,second is received as argument.

Example Usage:

$time->set_system_time({
              'month'         => $month,
              'day'           => $day,
              'year'          => $year,
              'hour'          => $hour,
              'minute'        => $minute,
              'second'        => $second,
        });

set_zoneinfo($$)

This function is used to set zone information. Region and area are passed as argument, so old symbolic link to /etc/localtime is deleted and new link is created according to /usr/share/zoneinfo/region/area.

Example Usage:

$time->set_zoneinfo($zone, $area);

3.2.5. AUTHORS

Ryan W. Maple <ryan@guardiandigital.com>

3.2.6. COPYRIGHT AND LICENSE

Copyright Guardian Digital, Inc., All Rights Reserved