1 # Functions for getting and setting the timezone on Linux
3 $timezones_file = "/usr/share/zoneinfo/zone.tab";
4 $currentzone_link = "/etc/localtime";
5 $timezones_dir = "/usr/share/zoneinfo";
11 &open_readfile(ZONE, $timezones_file) || return ( );
15 if (/^(\S+)\s+(\S+)\s+(\S+)\s+(\S.*)/) {
16 push(@rv, [ $3, $4 ]);
18 elsif (/^(\S+)\s+(\S+)\s+(\S+)/) {
19 push(@rv, [ $3, undef ]);
23 return sort { $a->[0] cmp $b->[0] } @rv;
26 # get_current_timezone()
27 sub get_current_timezone
29 local $lnk = readlink(&translate_filename($currentzone_link));
32 $lnk =~ s/$timezones_dir\///;
36 # Need to compare with all timezone files!
37 return &find_same_zone($currentzone_link);
41 # set_current_timezone(zone)
42 sub set_current_timezone
44 &lock_file($currentzone_link);
45 unlink(&translate_filename($currentzone_link));
46 symlink(&translate_filename("$timezones_dir/$_[0]"),
47 &translate_filename($currentzone_link));
48 &unlock_file($currentzone_link);
53 return -r $timezones_file;
58 return ( $currentzone_link );