| 1 | package Time::Timezone; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | require 5.008001; | |||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||
| 6 | 5 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | @EXPORT = qw(tz2zone tz_local_offset tz_offset tz_name); | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | 5 | @EXPORT_OK = qw(); | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # Parts stolen from code by Paul Foley <paul@ascent.com> | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | $VERSION = 2026.0330; | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | sub tz2zone | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tz2zone: not called CC=9 SCAR=42.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my($TZ, $time, $isdst) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use vars qw(%tzn_cache); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | $TZ = defined($ENV{'TZ'}) ? ( $ENV{'TZ'} ? $ENV{'TZ'} : 'GMT' ) : '' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | unless $TZ; | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # Hack to deal with 'PST8PDT' format of TZ | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # Note that this can't deal with all the esoteric forms, but it | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # does recognize the most common: [:]STDoff[DST[off][,rule]] | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | if (! defined $isdst) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $j; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $time = time() unless defined $time; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ($j, $j, $j, $j, $j, $j, $j, $j, $isdst) = localtime($time); | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | if (defined $tzn_cache{$TZ}->[$isdst]) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return $tzn_cache{$TZ}->[$isdst]; | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ($TZ =~ /^ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ( [^:\d+\-,] {3,} ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ( [+-] ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | \d {1,2} | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ( : \d {1,2} ) {0,2} | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ( [^\d+\-,] {3,} )? | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | /x | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $TZ = $isdst ? $4 : $1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $tzn_cache{$TZ} = [ $1, $4 ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $tzn_cache{$TZ} = [ $TZ, $TZ ]; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | return $TZ; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | sub tz_local_offset | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 28 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tz_local_offset: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 28 | my ($time) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 28 | ▶ | $time = time() unless defined $time; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 28 | return &calc_off($time); | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | sub calc_off | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 28 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calc_off: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 28 | my ($time) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 28 | my (@l) = localtime($time); | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 28 | my (@g) = gmtime($time); | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 28 | my $off; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 28 | $off = $l[0] - $g[0] | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | + ($l[1] - $g[1]) * 60 | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | + ($l[2] - $g[2]) * 3600; | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # subscript 7 is yday. | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 28 | ▶ | if ($l[7] == $g[7]) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # done | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } elsif ($l[7] == $g[7] + 1) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $off += 86400; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | } elsif ($l[7] == $g[7] - 1) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | $off -= 86400; | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | } elsif ($l[7] < $g[7]) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # crossed over a year boundary! | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # localtime is beginning of year, gmt is end | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # therefore local is ahead | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $off += 86400; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | $off -= 86400; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 28 | return $off; | |||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # constants | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # The rest of the file originally comes from Graham Barr <bodg@tiuk.ti.com> | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # Some references: | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # http://www.weltzeituhr.com/laender/zeitzonen_e.shtml | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # http://www.worldtimezone.com/wtz-names/timezonenames.html | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # http://www.timegenie.com/timezones.php | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | CONFIG: { | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 5 | ▶ | use vars qw(%dstZone %zoneOff %dstZoneOff %Zone); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 5 | %dstZone = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | "brst" => -2*3600, # Brazil Summer Time (East Daylight) | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | "adt" => -3*3600, # Atlantic Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | "edt" => -4*3600, # Eastern Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | "cdt" => -5*3600, # Central Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | "mdt" => -6*3600, # Mountain Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | "pdt" => -7*3600, # Pacific Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | "ydt" => -8*3600, # Yukon Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | "hdt" => -9*3600, # Hawaii Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | "bst" => +1*3600, # British Summer | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | "mest" => +2*3600, # Middle European Summer | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | "met dst" => +2*3600, # Middle European Summer | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | "sst" => +2*3600, # Swedish Summer | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | "fst" => +2*3600, # French Summer | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | "eest" => +3*3600, # Eastern European Summer | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | "cest" => +2*3600, # Central European Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | "wadt" => +8*3600, # West Australian Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | "kdt" => +10*3600, # Korean Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # "cadt" => +10*3600+1800, # Central Australian Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | "eadt" => +11*3600, # Eastern Australian Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | "nzdt" => +13*3600, # New Zealand Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # not included due to ambiguity: | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # IST Indian Standard Time +5.5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # Ireland Standard Time 0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | # Israel Standard Time +2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | # IDT Ireland Daylight Time +1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Israel Daylight Time +3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # AMST Amazon Standard Time / -3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # Armenia Standard Time +8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # BST Brazil Standard -3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 5 | %Zone = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | "gmt" => 0, # Greenwich Mean | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | "ut" => 0, # Universal (Coordinated) | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | "utc" => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | "wet" => 0, # Western European | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | "wat" => -1*3600, # West Africa | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | "azost" => -1*3600, # Azores Standard Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | "cvt" => -1*3600, # Cape Verde Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | "at" => -2*3600, # Azores | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | "fnt" => -2*3600, # Brazil Time (Extreme East - Fernando Noronha) | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | "ndt" => -2*3600-1800,# Newfoundland Daylight | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | "art" => -3*3600, # Argentina Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # For completeness. BST is also British Summer, and GST is also Guam Standard. | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # "gst" => -3*3600, # Greenland Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | "nft" => -3*3600-1800,# Newfoundland | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # "nst" => -3*3600-1800,# Newfoundland Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | "mnt" => -4*3600, # Brazil Time (West Standard - Manaus) | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | "ewt" => -4*3600, # U.S. Eastern War Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | "ast" => -4*3600, # Atlantic Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | "bot" => -4*3600, # Bolivia Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | "vet" => -4*3600, # Venezuela Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | "est" => -5*3600, # Eastern Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | "cot" => -5*3600, # Colombia Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | "act" => -5*3600, # Brazil Time (Extreme West - Acre) | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | "pet" => -5*3600, # Peru Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | "cst" => -6*3600, # Central Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | "cest" => +2*3600, # Central European Summer | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | "mst" => -7*3600, # Mountain Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | "pst" => -8*3600, # Pacific Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | "yst" => -9*3600, # Yukon Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | "hst" => -10*3600, # Hawaii Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | "cat" => -10*3600, # Central Alaska | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | "ahst" => -10*3600, # Alaska-Hawaii Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | "taht" => -10*3600, # Tahiti Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | "nt" => -11*3600, # Nome | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | "idlw" => -12*3600, # International Date Line West | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | "cet" => +1*3600, # Central European | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | "mez" => +1*3600, # Central European (German) | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | "met" => +1*3600, # Middle European | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | "mewt" => +1*3600, # Middle European Winter | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | "swt" => +1*3600, # Swedish Winter | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | "set" => +1*3600, # Seychelles | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | "fwt" => +1*3600, # French Winter | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | "west" => +1*3600, # Western Europe Summer Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | "eet" => +2*3600, # Eastern Europe, USSR Zone 1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | "ukr" => +2*3600, # Ukraine | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | "sast" => +2*3600, # South Africa Standard Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | "bt" => +3*3600, # Baghdad, USSR Zone 2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | "eat" => +3*3600, # East Africa Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # "it" => +3*3600+1800,# Iran | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | "irst" => +3*3600+1800,# Iran Standard Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | "zp4" => +4*3600, # USSR Zone 3 | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | "msd" => +4*3600, # Moscow Daylight Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | "sct" => +4*3600, # Seychelles Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | "zp5" => +5*3600, # USSR Zone 4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | "azst" => +5*3600, # Azerbaijan Summer Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | "mvt" => +5*3600, # Maldives Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | "uzt" => +5*3600, # Uzbekistan Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | "ist" => +5*3600+1800,# Indian Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | "zp6" => +6*3600, # USSR Zone 5 | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | "lkt" => +6*3600, # Sri Lanka Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | "pkst" => +6*3600, # Pakistan Summer Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | "yekst" => +6*3600, # Yekaterinburg Summer Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # For completeness. NST is also Newfoundland Stanard, and SST is also Swedish Summer. | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # "nst" => +6*3600+1800,# North Sumatra | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # "sst" => +7*3600, # South Sumatra, USSR Zone 6 | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | "wast" => +7*3600, # West Australian Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | "ict" => +7*3600, # Indochina Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | "wit" => +7*3600, # Western Indonesia Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # "jt" => +7*3600+1800,# Java (3pm in Cronusland!) | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | "cct" => +8*3600, # China Coast, USSR Zone 7 | ||||||||||||||||||||||||||||||||||||||||||||||
| 216 | "wst" => +8*3600, # West Australian Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | "hkt" => +8*3600, # Hong Kong | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | "bnt" => +8*3600, # Brunei Darussalam Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | "cit" => +8*3600, # Central Indonesia Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | "myt" => +8*3600, # Malaysia Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | "pht" => +8*3600, # Philippines Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | "sgt" => +8*3600, # Singapore Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | "jst" => +9*3600, # Japan Standard, USSR Zone 8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | "kst" => +9*3600, # Korean Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # "cast" => +9*3600+1800,# Central Australian Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | "east" => +10*3600, # Eastern Australian Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | "gst" => +10*3600, # Guam Standard, USSR Zone 9 | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | "nct" => +11*3600, # New Caledonia Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | "nzt" => +12*3600, # New Zealand | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | "nzst" => +12*3600, # New Zealand Standard | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | "fjt" => +12*3600, # Fiji Time | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | "idle" => +12*3600, # International Date Line East | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 5 | %zoneOff = reverse(%Zone); | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | 5 | %dstZoneOff = reverse(%dstZone); | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # Preferences | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 5 | $zoneOff{0} = 'gmt'; | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 5 | $dstZoneOff{3600} = 'bst'; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | sub tz_offset | ||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tz_offset: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my ($zone, $time) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | return &tz_local_offset() unless($zone); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | $time = time() unless defined $time; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my(@l) = localtime($time); | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | my $dst = $l[8]; | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $zone = lc $zone; | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if ($zone =~ /^([\-\+]\d{3,4})$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $sign = $1 < 0 ? -1 : 1 ; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $v = abs(0 + $1); | |||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | return $sign * 60 * (int($v / 100) * 60 + ($v % 100)); | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | ▶ | } elsif (exists $dstZone{$zone} && ($dst || !exists $Zone{$zone})) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
exists $Time::Timezone::dstZone{$zone} and $dst || !exists $Time::Timezone::Zone{$zone}
$dst or not exists $Time::Timezone::Zone{$zone}
MC/DC0%0/3
exists $Time::Timezone::dstZone{$zone} and $dst || !exists $Time::Timezone::Zone{$zone}
exists $Time::Timezone::dstZone{$zone}
$dst
not exists $Time::Timezone::Zone{$zone}
Truth table0%0/4
A and B or not(C)
A= exists $Time::Timezone::dstZone{$zone}B= $dstC= not exists $Time::Timezone::Zone{$zone}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | return $dstZone{$zone}; | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | } elsif(exists $Zone{$zone}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | return $Zone{$zone}; | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | sub tz_name | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tz_name: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my ($off, $time) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | $time = time() unless defined $time; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my(@l) = localtime($time); | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my $dst = $l[8]; | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if (exists $dstZoneOff{$off} && ($dst || !exists $zoneOff{$off})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
exists $Time::Timezone::dstZoneOff{$off} and $dst || !exists $Time::Timezone::zoneOff{$off}
$dst or not exists $Time::Timezone::zoneOff{$off}
MC/DC0%0/3
exists $Time::Timezone::dstZoneOff{$off} and $dst || !exists $Time::Timezone::zoneOff{$off}
exists $Time::Timezone::dstZoneOff{$off}
$dst
not exists $Time::Timezone::zoneOff{$off}
Truth table0%0/4
A and B or not(C)
A= exists $Time::Timezone::dstZoneOff{$off}B= $dstC= not exists $Time::Timezone::zoneOff{$off}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | return $dstZoneOff{$off}; | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | } elsif (exists $zoneOff{$off}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | return $zoneOff{$off}; | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | sprintf("%+05d", int($off / 60) * 100 + $off % 60); | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||