line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Wikibase::Datatype::Value::Time; |
2
|
|
|
|
|
|
|
|
3
|
52
|
|
|
52
|
|
1134477
|
use strict; |
|
52
|
|
|
|
|
228
|
|
|
52
|
|
|
|
|
1514
|
|
4
|
52
|
|
|
52
|
|
288
|
use warnings; |
|
52
|
|
|
|
|
167
|
|
|
52
|
|
|
|
|
1491
|
|
5
|
|
|
|
|
|
|
|
6
|
52
|
|
|
52
|
|
4731
|
use Mo qw(build default is); |
|
52
|
|
|
|
|
5625
|
|
|
52
|
|
|
|
|
358
|
|
7
|
52
|
|
|
52
|
|
50793
|
use Wikibase::Datatype::Utils qw(check_datetime check_entity); |
|
52
|
|
|
|
|
178
|
|
|
52
|
|
|
|
|
9884
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.29; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'Wikibase::Datatype::Value'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has after => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
default => 0, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has before => ( |
19
|
|
|
|
|
|
|
is => 'ro', |
20
|
|
|
|
|
|
|
default => 0, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has calendarmodel => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has precision => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
default => 11, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has timezone => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
default => 0, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub type { |
38
|
1
|
|
|
1
|
1
|
9
|
return 'time'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub BUILD { |
42
|
39
|
|
|
39
|
0
|
288
|
my $self = shift; |
43
|
|
|
|
|
|
|
|
44
|
39
|
100
|
|
|
|
203
|
if (! defined $self->{'calendarmodel'}) { |
45
|
37
|
|
|
|
|
130
|
$self->{'calendarmodel'} = 'Q1985727'; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
39
|
|
|
|
|
178
|
check_entity($self, 'calendarmodel'); |
49
|
|
|
|
|
|
|
|
50
|
38
|
|
|
|
|
228
|
check_datetime($self, 'value'); |
51
|
|
|
|
|
|
|
|
52
|
37
|
|
|
|
|
106
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=pod |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=encoding utf8 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Wikibase::Datatype::Value::Time - Wikibase time value datatype. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SYNOPSIS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Time; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Value::Time->new(%params); |
72
|
|
|
|
|
|
|
my $after = $obj->after; |
73
|
|
|
|
|
|
|
my $before = $obj->before; |
74
|
|
|
|
|
|
|
my $calendarmodel = $obj->calendarmodel; |
75
|
|
|
|
|
|
|
my $precision = $obj->precision; |
76
|
|
|
|
|
|
|
my $timezone = $obj->timezone; |
77
|
|
|
|
|
|
|
my $type = $obj->type; |
78
|
|
|
|
|
|
|
my $value = $obj->value; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 DESCRIPTION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This datatype is item class for representation of time. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 C<new> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Value::Time->new(%params); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Constructor. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns instance of object. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over 8 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * C<after> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
After. |
99
|
|
|
|
|
|
|
Default value is 0. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * C<before> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Before. |
104
|
|
|
|
|
|
|
Default value is 0. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * C<calendarmodel> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Calendar model. |
109
|
|
|
|
|
|
|
Default value is 'Q1985727' (proleptic Gregorian |
110
|
|
|
|
|
|
|
calendar). |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * C<precision> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Time precision. |
115
|
|
|
|
|
|
|
Default value is 11. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * C<timezone> |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Time zone. |
120
|
|
|
|
|
|
|
Default value is 0. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * C<value> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Time value. |
125
|
|
|
|
|
|
|
Parameter is required. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=back |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 C<after> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my $after = $obj->after; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Get after. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Returns number. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 C<before> |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $before = $obj->before; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Get before. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns number. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 C<calendarmodel> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
my $calendarmodel = $obj->calendarmodel; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Get calendar model. Unit is entity (e.g. /^Q\d+$/). |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Returns string. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 C<precision> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
my $precision = $obj->precision; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Get precision. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Returns number. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 C<timezone> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my $timezone = $obj->timezone; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Get time zone. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Returns number. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 C<type> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $type = $obj->type; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Get type. This is constant 'time'. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Returns string. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 C<value> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $value = $obj->value; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Get value. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Returns string. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 ERRORS |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
new(): |
188
|
|
|
|
|
|
|
From Wikibase::Datatype::Utils::check_datetime(): |
189
|
|
|
|
|
|
|
Parameter '%s' has bad date time. |
190
|
|
|
|
|
|
|
Value: %s |
191
|
|
|
|
|
|
|
Parameter '%s' has bad date time day value. |
192
|
|
|
|
|
|
|
Value: %s |
193
|
|
|
|
|
|
|
Parameter '%s' has bad date time hour value. |
194
|
|
|
|
|
|
|
Value: %s |
195
|
|
|
|
|
|
|
Parameter '%s' has bad date time minute value. |
196
|
|
|
|
|
|
|
Value: %s |
197
|
|
|
|
|
|
|
Parameter '%s' has bad date time month value. |
198
|
|
|
|
|
|
|
Value: %s |
199
|
|
|
|
|
|
|
Parameter '%s' has bad date time second value. |
200
|
|
|
|
|
|
|
Value: %s |
201
|
|
|
|
|
|
|
From Wikibase::Datatype::Utils::check_entity(): |
202
|
|
|
|
|
|
|
Parameter 'calendarmodel' must begin with 'Q' and number after it. |
203
|
|
|
|
|
|
|
From Wikibase::Datatype::Value::new(): |
204
|
|
|
|
|
|
|
Parameter 'value' is required. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 EXAMPLE |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=for comment filename=create_and_print_value_time.pl |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
use strict; |
211
|
|
|
|
|
|
|
use warnings; |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
use Wikibase::Datatype::Value::Time; |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# Object. |
216
|
|
|
|
|
|
|
my $obj = Wikibase::Datatype::Value::Time->new( |
217
|
|
|
|
|
|
|
'precision' => 10, |
218
|
|
|
|
|
|
|
'value' => '+2020-09-01T00:00:00Z', |
219
|
|
|
|
|
|
|
); |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# Get calendar model. |
222
|
|
|
|
|
|
|
my $calendarmodel = $obj->calendarmodel; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# Get precision. |
225
|
|
|
|
|
|
|
my $precision = $obj->precision; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# Get type. |
228
|
|
|
|
|
|
|
my $type = $obj->type; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# Get value. |
231
|
|
|
|
|
|
|
my $value = $obj->value; |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# Print out. |
234
|
|
|
|
|
|
|
print "Calendar model: $calendarmodel\n"; |
235
|
|
|
|
|
|
|
print "Precision: $precision\n"; |
236
|
|
|
|
|
|
|
print "Type: $type\n"; |
237
|
|
|
|
|
|
|
print "Value: $value\n"; |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# Output: |
240
|
|
|
|
|
|
|
# Calendar model: Q1985727 |
241
|
|
|
|
|
|
|
# Precision: 10 |
242
|
|
|
|
|
|
|
# Type: time |
243
|
|
|
|
|
|
|
# Value: +2020-09-01T00:00:00Z |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
L<Error::Pure>, |
248
|
|
|
|
|
|
|
L<Mo>, |
249
|
|
|
|
|
|
|
L<Wikibase::Datatype::Utils>, |
250
|
|
|
|
|
|
|
L<Wikibase::Datatype::Value>. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 SEE ALSO |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=over |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=item L<Wikibase::Datatype::Value> |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
Wikibase datatypes. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=back |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head1 REPOSITORY |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
L<https://github.com/michal-josef-spacek/Wikibase-Datatype> |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head1 AUTHOR |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
Michal Josef Špaček L<mailto:skim@cpan.org> |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
L<http://skim.cz> |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
© 2020-2023 Michal Josef Špaček |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
BSD 2-Clause License |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 VERSION |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
0.29 |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |