{"id":7369,"date":"2022-12-20T19:37:51","date_gmt":"2022-12-20T22:37:51","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/manatoolssharedtimezone-man3\/"},"modified":"2022-12-20T19:37:51","modified_gmt":"2022-12-20T22:37:51","slug":"manatoolssharedtimezone-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/manatoolssharedtimezone-man3\/","title":{"rendered":"ManaTools::Shared::TimeZone (man3)"},"content":{"rendered":"<h1 align=\"center\">ManaTools::Shared::TimeZone<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#SUPPORT\">SUPPORT<\/a><br \/> <a href=\"#AUTHOR\">AUTHOR<\/a><br \/> <a href=\"#COPYRIGHT and LICENSE\">COPYRIGHT and LICENSE<\/a><br \/> <a href=\"#METHODS\">METHODS<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">ManaTools::Shared::TimeZone \u2212 module to manage TimeZone settings<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">my $tz = ManaTools::Shared::TimeZone\u2212>new();<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This module allows to manage time zone settings.<\/p>\n<h2>SUPPORT <a name=\"SUPPORT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">You can find documentation for this module with the perldoc command:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">perldoc ManaTools::Shared::TimeZone<\/p>\n<h2>AUTHOR <a name=\"AUTHOR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Angelo Naselli <anaselli@linux.it><\/p>\n<h2>COPYRIGHT and LICENSE <a name=\"COPYRIGHT and LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright (C) 2014\u22122017, Angelo Naselli.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This program is free software; you can redistribute it and\/or modify it under the terms of the <small>GNU<\/small> General Public License version 2, as published by the Free Software Foundation.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This program is distributed in the hope that it will be useful, but <small>WITHOUT ANY WARRANTY<\/small> ; without even the implied warranty of <small>MERCHANTABILITY<\/small> or <small>FITNESS FOR A PARTICULAR PURPOSE.<\/small> See the <small>GNU<\/small> General Public License for more details.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">You should have received a copy of the <small>GNU<\/small> General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place \u2212 Suite 330, Boston, <small>MA 02111\u22121307, USA.<\/small><\/p>\n<h2>METHODS <a name=\"METHODS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>new \u2212 optional parameters<\/b> <i><br \/> timezone_prefix<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">optional parameter to set the system timezone directory, <br \/> default value is \/usr\/share\/zoneinfo<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>new \u2212 optional parameters<\/b> <i><br \/> ntp_configuration_file<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">optional parameter to set the ntp server configuration file, <br \/> it meant to be for testing purpose, do not set or it will <br \/> be considered as configuration file despite of what the ntp <br \/> service is.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>new \u2212 optional parameters<\/b> <i><br \/> ntp_conf_dir<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">optional parameter to set ntp configuration directory, <br \/> default value is \/etc\/ntp<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>new \u2212 optional parameters<\/b> <i><br \/> ntp_program<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">optional parameter to set the ntp program that runs into the <br \/> system, available value are chronyd, ntpd and systemd\u2212timesyncd. <br \/> Default value is evaluate by configuration file found in the <br \/> system, fallback choice is systemd\u2212timesyncd.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>attribute<\/b> <i><br \/> ntpServiceConfig<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This RO attribute is a HashRef containing managed ntp <br \/> service as key and related configuration file. <br \/> Allowed actions: <br \/> getNTPServiceConfig => retrieves config file from the <br \/> given ntp service <br \/> ntpServiceConfigPairs => Key,Value pairs access<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>attribute<\/b> <i><br \/> ntpServiceList<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This attribute is a ArrayRef containing the sorted list of <br \/> configured NTP service into the system, retrieving info from <br \/> services.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>new \u2212 optional parameters<\/b> <i><br \/> installer_or_livecd<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To inform the back\u2212end that is working during installer or <br \/> livecd. Useful if Time zone setting and using fix_system <br \/> to use the real time clock (see setLocalRTC and <br \/> writeConfiguration).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>refreshNTPServiceList<\/b> <i><small><br \/> DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Refresh the ntpServiceList attribute value, usefull <br \/> if any NTP service has been istalled after having <br \/> instantiated this object<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>get_timezone_prefix<\/b> <i><small><br \/> OUTPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">timezone_prefix: directory in which time zone files are<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Return the timezone directory (defualt: \/usr\/share\/zoneinfo)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>getTimeZones<\/b> <i><small><br \/> INPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$from_system: if present and its value is not 0 checks into timezone_prefix <br \/> directory and gets the list from there<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>OUTPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@l: ARRAY containing sorted time zones<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method returns the available timezones<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>setTimeZone<\/b> <i><small><br \/> INPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$new_time_zone: New time zone to be set<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method get the new time zone to set and performs <br \/> the setting<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>getTimeZone<\/b> <i><small><br \/> OUTPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$timezone: current time zone<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method returns the current timezone setting<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>setLocalRTC<\/b> <i><small><br \/> INPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$enable: bool value enable\/disable real time clock as <br \/> localtime <br \/> $fix_system: bool read or not the real time clock<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method enables\/disables the real time clock as <br \/> localtime (e.g. disable means set the rtc to UTC). <br \/> NOTE from dbus: <br \/> Use SetLocalRTC() to control whether the RTC is in <br \/> local time or UTC. It is strongly recommended to maintain <br \/> the RTC in UTC. Some OSes (Windows) however maintain the <br \/> RTC in local time which might make it necessary to enable <br \/> this feature. However, this creates various problems as <br \/> daylight changes might be missed. If fix_system is passed <br \/> &#8220;true&#8221; the time from the RTC is read again and the system <br \/> clock adjusted according to the new setting. <br \/> If fix_system is passed &#8220;false&#8221; the system time is written <br \/> to the RTC taking the new setting into account. <br \/> Use fix_system=true in installers and livecds where the <br \/> RTC is probably more reliable than the system time. <br \/> Use fix_system=false in configuration UIs that are run during <br \/> normal operation and where the system clock is probably more <br \/> reliable than the RTC.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>getLocalRTC<\/b> <i><small><br \/> OUTPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$localRTC: 1 if RTC is localtime 0 for UTC<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method returns the RTC localtime setting<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>setEmbeddedNTP<\/b> <i><small><br \/> INPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$enable: enable\/disable systemd NTP service<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method enables\/disables and starts\/stops systemd NTP service,<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>getEmbeddedNTP<\/b> <i><small><br \/> OUTPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$NTP: if systemd NTP is enabled<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method returns the systemd NTP service is running<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>setTime<\/b> <i><small><br \/> INPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$sec_since_epoch: Time in seconds since 1\/1\/1970<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method set the system time and sets the RTC also<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>readConfiguration<\/b> <i><small><br \/> OUTPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">hash reference containing: <br \/> UTC => HW clock is set as UTC <br \/> ZONE => Time Zone set<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method returns the time zone system settings as hash <br \/> reference<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>writeConfiguration<\/b> <i><small><br \/> INPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$info: hash containing: <br \/> UTC => HW clock is set as UTC <br \/> ZONE => Time Zone<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method sets the passed Time Zone configuration. <br \/> If installer_or_livecd attribute is set fix_system is <br \/> passed to setLocalRTC<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>ntpServers<\/b> <i><small><br \/> OUTPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">HASHREF containing ntp_server => zone info<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method returns an hash ref containing pairs ntp\u2212server, zone<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>ntpCurrentServers<\/b> <i><small><br \/> OUTPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">@servers: array of configured server<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the current ntp server address list read from configuration file<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>currentNTPService<\/b> <i><small><br \/> DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Returns the current ntp service<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>isNTPRunning<\/b> <i><small><br \/> DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method just returns if the given ntp server is running<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>setNTPConfiguration<\/b> <i><small><br \/> INPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$NTP_servers: HASH reference containing: <br \/> servers => Array reference containing NTP server addresses <br \/> pool => ntp pool address if any<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method writes into NTP configuration file new server address <br \/> settings (note that root rights are required) or it rises an <br \/> exception<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>enableAndStartNTP<\/b> <i><small><br \/> INPUT<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">$server: server address to be configured<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i><small>DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">This method writes into NTP configuration file new server address <br \/> settings<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>disableAndStopNTP<\/b> <i><small><br \/> DESCRIPTION<\/small><\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Disable and stop the ntp server<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  ManaTools::Shared::TimeZone \u2212 module to manage TimeZone settings <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3007,3683],"class_list":["post-7369","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-man3","tag-manatoolssharedtimezone"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7369"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7369\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}