line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kwiki::TimeZone; |
2
|
1
|
|
|
1
|
|
93078
|
use Kwiki::Plugin -Base; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use mixin 'Kwiki::Installer'; |
4
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
const class_id => 'time_zone'; |
7
|
|
|
|
|
|
|
const config_file => 'time_zone.yaml'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
10
|
|
|
|
|
|
|
$self->hub->config->add_file($self->config_file); |
11
|
|
|
|
|
|
|
my $registry = shift; |
12
|
|
|
|
|
|
|
$registry->add(preference => $self->time_zone); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub time_zone { |
16
|
|
|
|
|
|
|
my $p = $self->new_preference('time_zone'); |
17
|
|
|
|
|
|
|
$p->query('Enter your time zone.'); |
18
|
|
|
|
|
|
|
$p->type('pulldown'); |
19
|
|
|
|
|
|
|
my $default = eval { $self->hub->config->time_zone_default }; |
20
|
|
|
|
|
|
|
undef $@; |
21
|
|
|
|
|
|
|
$p->default($default || 'GMT'); |
22
|
|
|
|
|
|
|
my $choices = [ |
23
|
|
|
|
|
|
|
IDLW => "International Date Line West", |
24
|
|
|
|
|
|
|
NT => "Nome", |
25
|
|
|
|
|
|
|
AHST => "Alaska-Hawaii Standard", |
26
|
|
|
|
|
|
|
CAT => "Central Alaska", |
27
|
|
|
|
|
|
|
HST => "Hawaii Standard", |
28
|
|
|
|
|
|
|
HDT => "Hawaii Daylight", |
29
|
|
|
|
|
|
|
YST => "Yukon Standard", |
30
|
|
|
|
|
|
|
YDT => "Yukon Daylight", |
31
|
|
|
|
|
|
|
PST => "Pacific Standard", |
32
|
|
|
|
|
|
|
PDT => "Pacific Daylight", |
33
|
|
|
|
|
|
|
MST => "Mountain Standard", |
34
|
|
|
|
|
|
|
MDT => "Mountain Daylight", |
35
|
|
|
|
|
|
|
CST => "Central Standard", |
36
|
|
|
|
|
|
|
CDT => "Central Daylight", |
37
|
|
|
|
|
|
|
EST => "Eastern Standard", |
38
|
|
|
|
|
|
|
EDT => "Eastern Daylight", |
39
|
|
|
|
|
|
|
ST => "Atlantic Standard", |
40
|
|
|
|
|
|
|
ADT => "Atlantic Daylight", |
41
|
|
|
|
|
|
|
NST => "Newfoundland Standard", |
42
|
|
|
|
|
|
|
NDT => "Newfoundland Daylight", |
43
|
|
|
|
|
|
|
AT => "Azores", |
44
|
|
|
|
|
|
|
WAT => "West Africa", |
45
|
|
|
|
|
|
|
GMT => "Greenwich Mean", |
46
|
|
|
|
|
|
|
UT => "Universal (Coordinated)", |
47
|
|
|
|
|
|
|
WET => "Western European", |
48
|
|
|
|
|
|
|
BST => "British Summer", |
49
|
|
|
|
|
|
|
CET => "Central European", |
50
|
|
|
|
|
|
|
MET => "iddle European", |
51
|
|
|
|
|
|
|
MEWT => "Middle European Winter", |
52
|
|
|
|
|
|
|
SWT => "Swedish Winter", |
53
|
|
|
|
|
|
|
FWT => "French Winter", |
54
|
|
|
|
|
|
|
MEST => "Middle European Summer", |
55
|
|
|
|
|
|
|
SST => "Swedish Summer", |
56
|
|
|
|
|
|
|
FST => "French Summer", |
57
|
|
|
|
|
|
|
EET => "Eastern Europe, USSR Zone 1", |
58
|
|
|
|
|
|
|
CEST => "Central European Summer", |
59
|
|
|
|
|
|
|
BT => "Baghdad, USSR Zone 2", |
60
|
|
|
|
|
|
|
IT => "Iran", |
61
|
|
|
|
|
|
|
ZP4 => "USSR Zone 3", |
62
|
|
|
|
|
|
|
ZP5 => "USSR Zone 4", |
63
|
|
|
|
|
|
|
IST => "Indian Standard", |
64
|
|
|
|
|
|
|
ZP6 => "USSR Zone 5", |
65
|
|
|
|
|
|
|
WAST => "West Australian Standard", |
66
|
|
|
|
|
|
|
WADT => "West Australian Daylight", |
67
|
|
|
|
|
|
|
JT => "Java (3pm in Cronusland!)", |
68
|
|
|
|
|
|
|
TWN => "Taiwan", |
69
|
|
|
|
|
|
|
CCT => "China Coast, USSR Zone 7", |
70
|
|
|
|
|
|
|
JST => "Japan Standard, USSR Zone 8", |
71
|
|
|
|
|
|
|
CAST => "Central Australian Standard", |
72
|
|
|
|
|
|
|
CADT => "Central Australian Daylight", |
73
|
|
|
|
|
|
|
GST => "Guam Standard, USSR Zone 9", |
74
|
|
|
|
|
|
|
EAST => "Eastern Australian Standard", |
75
|
|
|
|
|
|
|
EADT => "Eastern Australian Daylight", |
76
|
|
|
|
|
|
|
NZT => "New Zealand", |
77
|
|
|
|
|
|
|
NZST => "New Zealand Standard", |
78
|
|
|
|
|
|
|
IDLE => "International Date Line East", |
79
|
|
|
|
|
|
|
NZDT => "New Zealand Daylight", |
80
|
|
|
|
|
|
|
]; |
81
|
|
|
|
|
|
|
$p->choices($choices); |
82
|
|
|
|
|
|
|
return $p; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $time_offsets = { |
86
|
|
|
|
|
|
|
IDLW => -12, |
87
|
|
|
|
|
|
|
NT => -11, |
88
|
|
|
|
|
|
|
AHST => -10, |
89
|
|
|
|
|
|
|
CAT => -10, |
90
|
|
|
|
|
|
|
HST => -10, |
91
|
|
|
|
|
|
|
HDT => -9, |
92
|
|
|
|
|
|
|
YST => -9, |
93
|
|
|
|
|
|
|
YDT => -8, |
94
|
|
|
|
|
|
|
PST => -8, |
95
|
|
|
|
|
|
|
PDT => -7, |
96
|
|
|
|
|
|
|
MST => -7, |
97
|
|
|
|
|
|
|
MDT => -6, |
98
|
|
|
|
|
|
|
CST => -6, |
99
|
|
|
|
|
|
|
CDT => -5, |
100
|
|
|
|
|
|
|
EST => -5, |
101
|
|
|
|
|
|
|
EDT => -4, |
102
|
|
|
|
|
|
|
ST => -4, |
103
|
|
|
|
|
|
|
ADT => -3, |
104
|
|
|
|
|
|
|
NST => -3.5, |
105
|
|
|
|
|
|
|
NDT => -2.5, |
106
|
|
|
|
|
|
|
AT => -2, |
107
|
|
|
|
|
|
|
WAT => -1, |
108
|
|
|
|
|
|
|
GMT => 0, |
109
|
|
|
|
|
|
|
UT => 0, |
110
|
|
|
|
|
|
|
WET => 0, |
111
|
|
|
|
|
|
|
BST => 1, |
112
|
|
|
|
|
|
|
CET => 1, |
113
|
|
|
|
|
|
|
MET => 1, |
114
|
|
|
|
|
|
|
MEWT => 1, |
115
|
|
|
|
|
|
|
SWT => 1, |
116
|
|
|
|
|
|
|
FWT => 1, |
117
|
|
|
|
|
|
|
MEST => 2, |
118
|
|
|
|
|
|
|
SST => 2, |
119
|
|
|
|
|
|
|
FST => 2, |
120
|
|
|
|
|
|
|
EET => 2, |
121
|
|
|
|
|
|
|
CEST => 2, |
122
|
|
|
|
|
|
|
BT => 3, |
123
|
|
|
|
|
|
|
IT => 3.5, |
124
|
|
|
|
|
|
|
ZP4 => 4, |
125
|
|
|
|
|
|
|
ZP5 => 5, |
126
|
|
|
|
|
|
|
IST => 5.5, |
127
|
|
|
|
|
|
|
ZP6 => 6, |
128
|
|
|
|
|
|
|
WAST => 7, |
129
|
|
|
|
|
|
|
WADT => 8, |
130
|
|
|
|
|
|
|
JT => 7.5, |
131
|
|
|
|
|
|
|
TWN => 8, |
132
|
|
|
|
|
|
|
CCT => 8, |
133
|
|
|
|
|
|
|
JST => 9, |
134
|
|
|
|
|
|
|
CAST => 9.5, |
135
|
|
|
|
|
|
|
CADT => 10.5, |
136
|
|
|
|
|
|
|
GST => 10, |
137
|
|
|
|
|
|
|
EAST => 10, |
138
|
|
|
|
|
|
|
EADT => 11, |
139
|
|
|
|
|
|
|
NZT => 12, |
140
|
|
|
|
|
|
|
NZST => 12, |
141
|
|
|
|
|
|
|
IDLE => 12, |
142
|
|
|
|
|
|
|
NZDT => 13, |
143
|
|
|
|
|
|
|
}; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub format { |
146
|
|
|
|
|
|
|
my $time = shift; |
147
|
|
|
|
|
|
|
my $time_zone = $self->preferences->time_zone->value || 'GMT'; |
148
|
|
|
|
|
|
|
my $offset = $time_offsets->{$time_zone} || 0; |
149
|
|
|
|
|
|
|
scalar(gmtime($time + $offset * 3600)) . " $time_zone"; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
__DATA__ |