File Coverage

blib/lib/DateTime/Format/CLDR.pm
Criterion Covered Total %
statement 236 242 97.5
branch 145 160 90.6
condition 71 98 72.4
subroutine 27 27 100.0
pod 11 11 100.0
total 490 538 91.0


line stmt bran cond sub pod time code
1             # ============================================================================
2             package DateTime::Format::CLDR;
3             # ============================================================================
4 17     17   2919406 use strict;
  17         27  
  17         419  
5 17     17   56 use warnings;
  17         25  
  17         365  
6 17     17   4444 use utf8;
  17         87  
  17         86  
7              
8 17     17   7695 use DateTime;
  17         2970778  
  17         572  
9 17     17   90 use DateTime::Locale 0.4000;
  17         348  
  17         308  
10 17     17   58 use DateTime::TimeZone;
  17         19  
  17         370  
11 17     17   8974 use Params::Validate qw( validate_pos validate SCALAR BOOLEAN OBJECT CODEREF );
  17         37369  
  17         1121  
12 17     17   89 use Exporter;
  17         21  
  17         506  
13 17     17   61 use Carp qw(croak carp);
  17         22  
  17         644  
14              
15             # Export functions
16 17     17   156 use base qw(Exporter);
  17         20  
  17         58280  
17             our @EXPORT_OK = qw( cldr_format cldr_parse );
18              
19             # CPAN data
20             our $AUTHORITY = 'cpan:MAROS';
21             our $VERSION = '1.18';
22              
23             # Default format if none is set
24             our $DEFAULT_FORMAT = 'date_format_medium';
25              
26             # Simple regexp blocks
27             our %PARTS = (
28             year_long => qr/(-?\d{1,4})/o,
29             year_short => qr/(-?\d{2})/o,
30             day_week => qr/([1-7])/o,
31             day_month => qr/(3[01]|[12]\d|0?[1-9])/o,
32             day_year => qr/([1-3]\d\d|0?[1-9]\d|(?:00)?[1-9])/o,
33             month => qr/(1[0-2]|0?[1-9])/o,
34             hour_23 => qr/(00|2[0-4]|1\d|0?\d)/o,
35             hour_24 => qr/(2[0-4]|1\d|0?[1-9])/o,
36             hour_12 => qr/(1[0-2]|0?[1-9])/o,
37             hour_11 => qr/(00|1[01]|0?\d)/o,
38             minute => qr/([0-5]?\d)/o,
39             second => qr/(6[01]|[0-5]?\d)/o,
40             quarter => qr/([1-4])/o,
41             week_year => qr/(5[0-3]|[1-4]\d|0?[1-9])/o,
42             week_month => qr/(\d)/o,
43             #timezone => qr/[+-](1[0-4]|0?\d)(00|15|30|45)/o,
44             number => qr/(\d+)/o,
45             timezone2 => qr/([A-Z1-9a-z]+)([+-](?:1[0-4]|0\d)(?:00|15|30|45))/o,
46             );
47              
48             # Table for mapping abbreviated timezone names to offsets
49             our %ZONEMAP = (
50             'A' => '+0100', 'ACDT' => '+1030', 'ACST' => '+0930',
51             'ADT' => 'Ambiguous', 'AEDT' => '+1100', 'AES' => '+1000',
52             'AEST' => '+1000', 'AFT' => '+0430', 'AHDT' => '-0900',
53             'AHST' => '-1000', 'AKDT' => '-0800', 'AKST' => '-0900',
54             'AMST' => '+0400', 'AMT' => '+0400', 'ANAST' => '+1300',
55             'ANAT' => '+1200', 'ART' => '-0300', 'AST' => 'Ambiguous',
56             'AT' => '-0100', 'AWST' => '+0800', 'AZOST' => '+0000',
57             'AZOT' => '-0100', 'AZST' => '+0500', 'AZT' => '+0400',
58             'B' => '+0200', 'BADT' => '+0400', 'BAT' => '+0600',
59             'BDST' => '+0200', 'BDT' => '+0600', 'BET' => '-1100',
60             'BNT' => '+0800', 'BORT' => '+0800', 'BOT' => '-0400',
61             'BRA' => '-0300', 'BST' => 'Ambiguous', 'BT' => 'Ambiguous',
62             'BTT' => '+0600', 'C' => '+0300', 'CAST' => '+0930',
63             'CAT' => 'Ambiguous', 'CCT' => 'Ambiguous', 'CDT' => 'Ambiguous',
64             'CEST' => '+0200', 'CET' => '+0100', 'CETDST' => '+0200',
65             'CHADT' => '+1345', 'CHAST' => '+1245', 'CKT' => '-1000',
66             'CLST' => '-0300', 'CLT' => '-0400', 'COT' => '-0500',
67             'CST' => 'Ambiguous', 'CSuT' => '+1030', 'CUT' => '+0000',
68             'CVT' => '-0100', 'CXT' => '+0700', 'ChST' => '+1000',
69             'D' => '+0400', 'DAVT' => '+0700', 'DDUT' => '+1000',
70             'DNT' => '+0100', 'DST' => '+0200', 'E' => '+0500',
71             'EASST' => '-0500', 'EAST' => 'Ambiguous', 'EAT' => '+0300',
72             'ECT' => 'Ambiguous', 'EDT' => 'Ambiguous', 'EEST' => '+0300',
73             'EET' => '+0200', 'EETDST' => '+0300', 'EGST' => '+0000',
74             'EGT' => '-0100', 'EMT' => '+0100', 'EST' => 'Ambiguous',
75             'ESuT' => '+1100', 'F' => '+0600', 'FDT' => 'Ambiguous',
76             'FJST' => '+1300', 'FJT' => '+1200', 'FKST' => '-0300',
77             'FKT' => '-0400', 'FST' => 'Ambiguous', 'FWT' => '+0100',
78             'G' => '+0700', 'GALT' => '-0600', 'GAMT' => '-0900',
79             'GEST' => '+0500', 'GET' => '+0400', 'GFT' => '-0300',
80             'GILT' => '+1200', 'GMT' => '+0000', 'GST' => 'Ambiguous',
81             'GT' => '+0000', 'GYT' => '-0400', 'GZ' => '+0000',
82             'H' => '+0800', 'HAA' => '-0300', 'HAC' => '-0500',
83             'HAE' => '-0400', 'HAP' => '-0700', 'HAR' => '-0600',
84             'HAT' => '-0230', 'HAY' => '-0800', 'HDT' => '-0930',
85             'HFE' => '+0200', 'HFH' => '+0100', 'HG' => '+0000',
86             'HKT' => '+0800', 'HL' => 'local', 'HNA' => '-0400',
87             'HNC' => '-0600', 'HNE' => '-0500', 'HNP' => '-0800',
88             'HNR' => '-0700', 'HNT' => '-0330', 'HNY' => '-0900',
89             'HOE' => '+0100', 'HST' => '-1000', 'I' => '+0900',
90             'ICT' => '+0700', 'IDLE' => '+1200', 'IDLW' => '-1200',
91             'IDT' => 'Ambiguous', 'IOT' => '+0500', 'IRDT' => '+0430',
92             'IRKST' => '+0900', 'IRKT' => '+0800', 'IRST' => '+0430',
93             'IRT' => '+0330', 'IST' => 'Ambiguous', 'IT' => '+0330',
94             'ITA' => '+0100', 'JAVT' => '+0700', 'JAYT' => '+0900',
95             'JST' => '+0900', 'JT' => '+0700', 'K' => '+1000',
96             'KDT' => '+1000', 'KGST' => '+0600', 'KGT' => '+0500',
97             'KOST' => '+1200', 'KRAST' => '+0800', 'KRAT' => '+0700',
98             'KST' => '+0900', 'L' => '+1100', 'LHDT' => '+1100',
99             'LHST' => '+1030', 'LIGT' => '+1000', 'LINT' => '+1400',
100             'LKT' => '+0600', 'LST' => 'local', 'LT' => 'local',
101             'M' => '+1200', 'MAGST' => '+1200', 'MAGT' => '+1100',
102             'MAL' => '+0800', 'MART' => '-0930', 'MAT' => '+0300',
103             'MAWT' => '+0600', 'MDT' => '-0600', 'MED' => '+0200',
104             'MEDST' => '+0200', 'MEST' => '+0200', 'MESZ' => '+0200',
105             'MET' => 'Ambiguous', 'MEWT' => '+0100', 'MEX' => '-0600',
106             'MEZ' => '+0100', 'MHT' => '+1200', 'MMT' => '+0630',
107             'MPT' => '+1000', 'MSD' => '+0400', 'MSK' => '+0300',
108             'MSKS' => '+0400', 'MST' => '-0700', 'MT' => '+0830',
109             'MUT' => '+0400', 'MVT' => '+0500', 'MYT' => '+0800',
110             'N' => '-0100', 'NCT' => '+1100', 'NDT' => '-0230',
111             'NFT' => 'Ambiguous', 'NOR' => '+0100', 'NOVST' => '+0700',
112             'NOVT' => '+0600', 'NPT' => '+0545', 'NRT' => '+1200',
113             'NST' => 'Ambiguous', 'NSUT' => '+0630', 'NT' => '-1100',
114             'NUT' => '-1100', 'NZDT' => '+1300', 'NZST' => '+1200',
115             'NZT' => '+1200', 'O' => '-0200', 'OESZ' => '+0300',
116             'OEZ' => '+0200', 'OMSST' => '+0700', 'OMST' => '+0600',
117             'OZ' => 'local', 'P' => '-0300', 'PDT' => '-0700',
118             'PET' => '-0500', 'PETST' => '+1300', 'PETT' => '+1200',
119             'PGT' => '+1000', 'PHOT' => '+1300', 'PHT' => '+0800',
120             'PKT' => '+0500', 'PMDT' => '-0200', 'PMT' => '-0300',
121             'PNT' => '-0830', 'PONT' => '+1100', 'PST' => 'Ambiguous',
122             'PWT' => '+0900', 'PYST' => '-0300', 'PYT' => '-0400',
123             'Q' => '-0400', 'R' => '-0500', 'R1T' => '+0200',
124             'R2T' => '+0300', 'RET' => '+0400', 'ROK' => '+0900',
125             'S' => '-0600', 'SADT' => '+1030', 'SAST' => 'Ambiguous',
126             'SBT' => '+1100', 'SCT' => '+0400', 'SET' => '+0100',
127             'SGT' => '+0800', 'SRT' => '-0300', 'SST' => 'Ambiguous',
128             'SWT' => '+0100', 'T' => '-0700', 'TFT' => '+0500',
129             'THA' => '+0700', 'THAT' => '-1000', 'TJT' => '+0500',
130             'TKT' => '-1000', 'TMT' => '+0500', 'TOT' => '+1300',
131             'TRUT' => '+1000', 'TST' => '+0300', 'TUC ' => '+0000',
132             'TVT' => '+1200', 'U' => '-0800', 'ULAST' => '+0900',
133             'ULAT' => '+0800', 'USZ1' => '+0200', 'USZ1S' => '+0300',
134             'USZ3' => '+0400', 'USZ3S' => '+0500', 'USZ4' => '+0500',
135             'USZ4S' => '+0600', 'USZ5' => '+0600', 'USZ5S' => '+0700',
136             'USZ6' => '+0700', 'USZ6S' => '+0800', 'USZ7' => '+0800',
137             'USZ7S' => '+0900', 'USZ8' => '+0900', 'USZ8S' => '+1000',
138             'USZ9' => '+1000', 'USZ9S' => '+1100', 'UTZ' => '-0300',
139             'UYT' => '-0300', 'UZ10' => '+1100', 'UZ10S' => '+1200',
140             'UZ11' => '+1200', 'UZ11S' => '+1300', 'UZ12' => '+1200',
141             'UZ12S' => '+1300', 'UZT' => '+0500', 'V' => '-0900',
142             'VET' => '-0400', 'VLAST' => '+1100', 'VLAT' => '+1000',
143             'VTZ' => '-0200', 'VUT' => '+1100', 'W' => '-1000',
144             'WAKT' => '+1200', 'WAST' => 'Ambiguous', 'WAT' => '+0100',
145             'WEST' => '+0100', 'WESZ' => '+0100', 'WET' => '+0000',
146             'WETDST' => '+0100', 'WEZ' => '+0000', 'WFT' => '+1200',
147             'WGST' => '-0200', 'WGT' => '-0300', 'WIB' => '+0700',
148             'WIT' => '+0900', 'WITA' => '+0800', 'WST' => 'Ambiguous',
149             'WTZ' => '-0100', 'WUT' => '+0100', 'X' => '-1100',
150             'Y' => '-1200', 'YAKST' => '+1000', 'YAKT' => '+0900',
151             'YAPT' => '+1000', 'YDT' => '-0800', 'YEKST' => '+0600',
152             'YEKT' => '+0500', 'YST' => '-0900', 'Z' => '+0000',
153             );
154              
155             # Map of CLDR commands to values
156             # Value might be
157             # - Regular expression: usually taken from %PART
158             # - String: DateTime::Locale method names. Method must retun lists of valid values
159             # - Arrayref: List of valid values
160              
161             our %PARSER = (
162             G1 => 'era_abbreviated',
163             G4 => 'era_wide',
164             G5 => 'era_narrow',
165             y1 => $PARTS{year_long},
166             y2 => $PARTS{year_short},
167             y3 => qr/(-?\d{3,4})/o,
168             y4 => qr/(-?\d{4})/o,
169             y5 => qr/(-?\d{5})/o,
170             Y1 => $PARTS{year_long},
171             u1 => $PARTS{year_long},
172             Q1 => $PARTS{quarter},
173             Q3 => 'quarter_format_abbreviated',
174             Q4 => 'quarter_format_wide',
175             q1 => $PARTS{quarter},
176             q3 => 'quarter_stand_alone_abbreviated',
177             q4 => 'quarter_stand_alone_wide',
178             M1 => $PARTS{month},
179             M3 => 'month_format_abbreviated',
180             M4 => 'month_format_wide',
181             M5 => 'month_format_narrow',
182             L1 => $PARTS{month},
183             L3 => 'month_stand_alone_abbreviated',
184             L4 => 'month_stand_alone_wide',
185             L5 => 'month_stand_alone_narrow',
186             w1 => $PARTS{week_year},
187             W1 => $PARTS{week_month},
188             d1 => $PARTS{day_month},
189             D1 => $PARTS{day_year},
190             F1 => $PARTS{week_month},
191             E1 => 'day_format_abbreviated',
192             E4 => 'day_format_wide',
193             E5 => 'day_format_narrow',
194             e1 => $PARTS{day_week},
195             e3 => 'day_format_abbreviated',
196             e4 => 'day_format_wide',
197             e5 => 'day_format_narrow',
198             c1 => $PARTS{day_week},
199             c3 => 'day_stand_alone_abbreviated',
200             c4 => 'day_stand_alone_wide',
201             c5 => 'day_stand_alone_narrow',
202             a1 => 'am_pm_abbreviated',
203             h1 => $PARTS{hour_12},
204             H1 => $PARTS{hour_23},
205             K1 => $PARTS{hour_11},
206             k1 => $PARTS{hour_24},
207             #j1 => Handled dyamically,
208             m1 => $PARTS{minute},
209             s1 => $PARTS{second},
210             S1 => $PARTS{number}, #!
211             Z1 => [ grep { $_ ne 'Ambiguous' } values %ZONEMAP ],
212             Z4 => $PARTS{timezone2},
213             z1 => [ keys %ZONEMAP ],
214             z4 => [ DateTime::TimeZone->all_names ],
215             );
216             $PARSER{v1} = $PARSER{V1} = $PARSER{z1};
217             $PARSER{v4} = $PARSER{V4} = $PARSER{z4};
218              
219              
220             =encoding utf8
221              
222             =head1 NAME
223              
224             DateTime::Format::CLDR - Parse and format CLDR time patterns
225              
226             =head1 SYNOPSIS
227              
228             use DateTime::Format::CLDR;
229              
230             # 1. Basic example
231             my $cldr1 = DateTime::Format::CLDR->new(
232             pattern => 'HH:mm:ss',
233             locale => 'de_AT',
234             time_zone => 'Europe/Vienna',
235             );
236              
237             my $dt1 = $cldr1->parse_datetime('23:16:42');
238              
239             print $cldr1->format_datetime($dt1);
240             # 23:16:42
241              
242             # 2. Get pattern from selected locale
243             # pattern is taken from 'date_format_medium' in DateTime::Locale::de_AT
244             my $cldr2 = DateTime::Format::CLDR->new(
245             locale => 'de_AT',
246             );
247              
248             print $cldr2->parse_datetime('23.11.2007');
249             # 2007-11-23T00:00:00
250              
251             # 3. Croak when things go wrong
252             my $cldr3 = DateTime::Format::CLDR->new(
253             locale => 'de_AT',
254             on_error => 'croak',
255             );
256              
257             $cldr3->parse_datetime('23.33.2007');
258             # Croaks
259              
260             # 4. Use DateTime::Locale
261             my $locale = DateTime::Locale->load('en_GB');
262             my $cldr4 = DateTime::Format::CLDR->new(
263             pattern => $locale->datetime_format_medium,
264             locale => $locale,
265             );
266              
267             print $cldr4->parse_datetime('22 Dec 1995 09:05:02');
268             # 1995-12-22T09:05:02
269              
270             =head1 DESCRIPTION
271              
272             This module provides a parser (and also a formater) for datetime strings
273             using patterns as defined by the Unicode CLDR Project
274             (Common Locale Data Repository). L<http://unicode.org/cldr/>.
275              
276             CLDR format is supported by L<DateTime> and L<DateTime::Locale> starting with
277             version 0.40.
278              
279             =head1 METHODS
280              
281             =head2 Constructor
282              
283             =head3 new
284              
285             DateTime::Format::CLDR->new(%PARAMS);
286              
287             The following parameters are used by DateTime::Format::CLDR:
288              
289             =over
290              
291             =item * locale
292              
293             Locale.
294              
295             See L<locale> accessor.
296              
297             =item * pattern (optional)
298              
299             CLDR pattern. If you don't provide a pattern the C<date_format_medium>
300             pattern from L<DateTime::Local> for the selected locale will be used.
301              
302             See L<pattern> accessor.
303              
304             =item * time_zone (optional)
305              
306             Timezone that should be used by default. If your pattern contains
307             timezone information this attribute will be ignored.
308              
309             See L<time_zone> accessor.
310              
311             =item * on_error (optional)
312              
313             Set the error behaviour.
314              
315             See L<on_error> accessor.
316              
317             =item * incomplete (optional)
318              
319             Set the behaviour how to handle incomplete date information.
320              
321             See L<incomplete> accessor.
322              
323             =back
324              
325             =cut
326              
327             sub new { ## no perlcritic(RequireArgUnpacking)
328 113     113 1 91862 my $class = shift;
329 113         3378 my %args = validate( @_, {
330             locale => { type => SCALAR | OBJECT, default => 'en' },
331             pattern => { type => SCALAR, optional => 1 },
332             time_zone => { type => SCALAR | OBJECT, optional => 1 },
333             on_error => { type => SCALAR | CODEREF, optional => 1, default => 'undef' },
334             incomplete => { type => SCALAR | CODEREF, optional => 1, default => 1 },
335             }
336             );
337              
338 113         625 my $self = bless \%args, $class;
339              
340             # Set default values
341 113   66     635 $args{time_zone} ||= DateTime::TimeZone->new( name => 'floating' );
342              
343             # Pass on to accessors
344 113         5048 $self->time_zone($args{time_zone});
345 113         272 $self->locale($args{locale});
346              
347             # Set default values
348 113 100       483 unless (defined $args{pattern}) {
349 6 50       18 if ($self->locale->can($DEFAULT_FORMAT)) {
350 6         9 $args{pattern} = $self->locale->$DEFAULT_FORMAT;
351             } else {
352 0         0 croak("Method '$DEFAULT_FORMAT' not available in ".ref($self->loclale));
353             }
354             }
355              
356 113         272 $self->pattern($args{pattern});
357 113         231 $self->on_error($args{on_error});
358 113         233 $self->incomplete($args{incomplete});
359 113         148 $self->{errmsg} = undef;
360              
361 113         316 return $self;
362             }
363              
364             =head2 Accessors
365              
366             =head3 pattern
367              
368             Get/set CLDR pattern. See L<"CLDR PATTERNS"> or L<DateTime/"CLDR Patterns">
369             for details about patterns.
370              
371             $cldr->pattern('d MMM y HH:mm:ss');
372              
373             It is possible to retrieve patterns from L<DateTime::Locale>
374              
375             $dl = DateTime::Locale->load('es_AR');
376             $cldr->pattern($dl->datetime_format_full);
377              
378             =cut
379              
380             sub pattern {
381 128     128 1 4282 my ($self,$pattern) = @_;
382              
383             # Set pattern
384 128 100       266 if (defined $pattern) {
385 114         141 $self->{pattern} = $pattern;
386 114         130 undef $self->{_built_pattern};
387             }
388              
389 128         193 return $self->{pattern};
390             }
391              
392             =head3 time_zone
393              
394             Get/set time_zone. Returns a C<DateTime::TimeZone> object.
395              
396             Accepts either a timezone name or a C<DateTime::TimeZone> object.
397              
398             $cldr->time_zone('America/Argentina/Mendoza');
399             OR
400             my $tz = DateTime::TimeZone->new(name => 'America/Argentina/Mendoza');
401             $cldr->time_zone($tz);
402              
403             =cut
404              
405             sub time_zone {
406 118     118 1 1898 my ($self,$time_zone) = @_;
407              
408             # Set timezone
409 118 100       239 if (defined $time_zone) {
410 116 100 66     755 if (ref $time_zone
411             && $time_zone->isa('DateTime::TimeZone')) {
412 109         216 $self->{time_zone} = $time_zone;
413             } else {
414 7 50       53 $self->{time_zone} = DateTime::TimeZone->new( name => $time_zone )
415             or croak("Could not create timezone from $time_zone");
416             }
417             }
418              
419 116         54623 return $self->{time_zone};
420             }
421              
422             =head3 locale
423              
424             Get/set a locale. Returns a C<DateTime::Locale> object.
425              
426             Accepts either a locale name or a C<DateTime::Locale::*> object.
427              
428             $cldr->locale('fr_CA');
429             OR
430             $dl = DateTime::Locale->load('fr_CA');
431             $cldr->locale($dl);
432              
433             =cut
434              
435             sub locale {
436 129     129 1 627 my ($self,$locale) = @_;
437              
438             # Set locale
439 129 100       249 if (defined $locale) {
440 115 100 66     430 unless (ref $locale
441             && ($locale->isa('DateTime::Locale::Base') || $locale->isa('DateTime::Locale::FromData'))) {
442 101 50       394 $self->{locale} = DateTime::Locale->load( $locale )
443             or croak("Could not create locale from $locale");
444             } else {
445 14         27 $self->{locale} = $locale;
446             }
447 114         5958 undef $self->{_built_pattern};
448             }
449              
450 128         207 return $self->{locale};
451             }
452              
453             =head3 on_error
454              
455             Get/set the error behaviour.
456              
457             Accepts the following values
458              
459             =over
460              
461             =item * 'undef' (Literal) (default)
462              
463             Returns undef on error and sets L<errmsg>
464              
465             =item * 'croak'
466              
467             Croak on error
468              
469             =item * CODEREF
470              
471             Run the given coderef on error.
472              
473             =back
474              
475             =cut
476              
477             sub on_error {
478 115     115 1 646 my ($self,$on_error) = @_;
479              
480             # Set locale
481 115 100       224 if (defined $on_error) {
482 114 100 100     659 croak("The value supplied to on_error must be either 'croak', 'undef' or a code reference.")
      100        
483             unless ref($on_error) eq 'CODE'
484             or $on_error eq 'croak'
485             or $on_error eq 'undef';
486 113         166 return $self->{on_error};
487             }
488 1         3 return $self->{on_error};
489             }
490              
491             =head3 incomplete
492              
493             Set the behaviour how to handle incomplete Date information.
494              
495             Accepts the following values
496              
497             =over
498              
499             =item * '1' (default)
500              
501             Sets the missing values to '1'. Thus if you only parse a time sting you would
502             get '0001-01-01' as the date.
503              
504             =item * 'incomplete'
505              
506             Create a L<DateTime::Incomplete> object instead.
507              
508             =item * CODEREF
509              
510             Run the given coderef on incomplete values. The code reference will be
511             called with the C<DateTime::Format::CLDR> object and a hash of parsed values
512             as supplied to C<DateTime-E<gt>new>. It should return a modified hash which
513             will be passed to C<DateTime-E<gt>new>.
514              
515             =back
516              
517             =cut
518              
519             sub incomplete {
520 115     115 1 751 my ($self,$incomplete) = @_;
521              
522             # Set locale
523 115 100       208 if (defined $incomplete) {
524 114 100 100     502 croak("The value supplied to incomplete must be either 'incomplete', '1' or a code reference.")
      100        
525             unless ref($incomplete) eq 'CODE'
526             or $incomplete eq '1'
527             or $incomplete eq 'incomplete';
528 113         131 return $self->{incomplete};
529             }
530 1         5 return $self->{incomplete};
531             }
532              
533             =head2 Public Methods
534              
535             =head3 parse_datetime
536              
537             my $datetime = $cldr->parse_datetime($string);
538              
539             Parses a string and returns a C<DateTime> object on success (If you provide
540             incomplete data and set the L<incomplete> attribute accordingly it will
541             return a C<DateTime::Incomplete> object). If the string cannot be parsed
542             an error will be thrown (depending on the C<on_error> attribute).
543              
544             =cut
545              
546             sub parse_datetime { ## no perlcritic(RequireArgUnpacking)
547 12763     12763 1 5077169 my ( $self, $string ) = validate_pos( @_, 1, { type => SCALAR } );
548              
549 12763         34781 my $pattern = $self->_build_pattern();
550              
551 12763         12494 my $datetime_initial = $string;
552 12763         14212 my %datetime_info = ();
553 12763         12177 my %datetime_check = ();
554             my $datetime_error = sub {
555 7     7   10 my $occurence = shift;
556 7         6 my $error = $datetime_initial;
557 7         17 substr($error,(length($occurence) * -1),0," HERE-->");
558 7         26 return $self->_local_croak("Could not get datetime for $datetime_initial (Error marked by 'HERE-->'): '$error'");
559 12763         39468 };
560              
561             # Set default datetime values
562             my %datetime = (
563             hour => 0,
564             minute => 0,
565             second => 0,
566             time_zone => $self->{time_zone},
567             locale => $self->{locale},
568 12763         41433 nanosecond => 0,
569             );
570              
571 12763         10211 PART: foreach my $part (@{$pattern}) {
  12763         18778  
572              
573             #my $before = $string;
574              
575             # Pattern
576 162427 100       992919 if (ref $part eq 'ARRAY') {
    100          
577 76812         50706 my ($regexp,$command,$index) = @{$part};
  76812         140720  
578              
579             #print "TRY TO MATCH '$string' AGAINST '$regexp' WITH $command\n";
580              
581             # Match regexp part
582 76812 100       6190701 return $datetime_error->($string)
583             unless ($string =~ s/^ \s* $regexp//ix);
584              
585             # Get capture
586 76808         386253 my $capture = $1;
587              
588             # Pattern is a list: get index instead of value
589 76808 100       178812 if (ref $PARSER{$command.$index} eq '') {
590 14044         15828 my $function = $PARSER{$command.$index};
591 14044         10396 my $count = 1;
592 14044         8799 my $tmpcapture;
593 14044         8884 foreach my $element (@{$self->{locale}->$function}) {
  14044         50247  
594 98441 100       254301 if (lc($element) eq lc($capture)) {
595 14045 100       21178 if (defined $tmpcapture) {
596 1         5 $self->_local_carp("Expression '$capture' is ambigous for pattern '$command$index' ");
597 1         3 next PART;
598             }
599 14044         10464 $tmpcapture = $count;
600             }
601 98440         69515 $count ++;
602             }
603 14043         15093 $capture = $tmpcapture;
604             }
605              
606             # Run patterns
607 76807 100 100     811555 if ($command eq 'G' ) {
    100 100        
    100 100        
    100 100        
    100 100        
    100 100        
    100 33        
    100 66        
    100 33        
    100 33        
    100          
    100          
    100          
    100          
    100          
    100          
    100          
    100          
    100          
    100          
    100          
    100          
    50          
608 15         33 $datetime_info{era} = $capture;
609             } elsif ($command eq 'y' && $index == 2) {
610 750         969 $datetime{year} = $capture;
611 750 100       1397 if ($datetime{year} >= 70) {
612 372         751 $datetime{year} += 1900;
613             } else {
614 378         661 $datetime{year} += 2000;
615             }
616             } elsif ($command eq 'y' ) {
617 9090         20459 $datetime{year} = $capture;
618             } elsif ($command eq 'Q' || $command eq 'q') {
619 30         64 $datetime_check{quarter} = $capture;
620             } elsif ($command eq 'M' || $command eq 'L') {
621 9862         23722 $datetime{month} = $capture;
622             } elsif ($command eq 'w') {
623 5         12 $datetime_check{week_number} = $capture;
624             } elsif ($command eq 'W') {
625 5         11 $datetime_check{week_of_month} = $capture;
626             } elsif ($command eq 'd') {
627 9824         25046 $datetime{day} = $capture;
628             } elsif ($command eq 'D') {
629 5         12 $datetime_check{day_of_year} = $capture;
630             } elsif ($command eq 'e' && $index == 1) {
631 5         18 my $fdow = $self->{locale}->first_day_of_week();
632 5         18 $capture -= (8 - $fdow);
633 5 100       8 $capture += 7 if $capture < 1;
634 5         12 $datetime_check{day_of_week} = $capture;
635             } elsif ($command eq 'E' || $command eq 'c' || $command eq 'e') {
636 2223         5776 $datetime_check{day_of_week} = $capture;
637             } elsif ($command eq 'F') {
638 5         10 $datetime_check{weekday_of_month} = $capture;
639             } elsif ($command eq 'a' ) {
640 5868         11472 $datetime_info{ampm} = $capture;
641             } elsif ($command eq 'h') { # 1-12
642 5864 100       11871 $capture = 0 if $capture == 12;
643 5864         12458 $datetime_info{hour12} = $capture;
644             } elsif ($command eq 'K') { # 0-11
645 4         10 $datetime_info{hour12} = $capture;
646             } elsif ($command eq 'H') { # 0-23
647 6680         16529 $datetime{hour} = $capture;
648             } elsif ($command eq 'k') { # 1-24
649 8         18 $datetime_info{hour24} = $capture;
650             } elsif ($command eq 'm') {
651 12190         26105 $datetime{minute} = $capture;
652             } elsif ($command eq 's') {
653 9489         20793 $datetime{second} = $capture;
654             } elsif ($command eq 'S' ) {
655 12         51 $datetime{nanosecond} = int("0.$capture" * 1000000000);
656             } elsif ($command eq 'Z') {
657 240 100       361 if ($index >= 4) {
658 120         172 $capture = $2;
659             }
660 240         846 $datetime{time_zone} = DateTime::TimeZone->new( name => $capture );
661             } elsif (($command eq 'z' || $command eq 'v' || $command eq 'V') && $index == 1) {
662 2317 100 66     8766 if (! defined $ZONEMAP{$capture}
663             || $ZONEMAP{$capture} eq 'Ambiguous') {
664 1         6 $self->_local_carp("Ambiguous timezone: $capture $command");
665 1         3 next;
666             }
667 2316         8631 $datetime{time_zone} = DateTime::TimeZone->new(name => $ZONEMAP{$capture});
668             } elsif ($command eq 'z' || $command eq 'v' || $command eq 'V') {
669 2316         8665 $datetime{time_zone} = DateTime::TimeZone->new(name => $capture);
670             } else {
671 0         0 return $self->_local_croak("Could not get datetime for '$datetime_initial': Unknown pattern $command$index");
672             }
673              
674             # String
675             } elsif ($string !~ s/^ \s* $part//ix) {
676 2         7 return $datetime_error->($string);
677             }
678             #print "BEFORE: '$before' AFTER: '$string' PATTERN: '$part'\n";
679             }
680              
681 12757 100       603888 return $datetime_error->($string)
682             if $string ne '';
683              
684             # Handle 12 hour time notations
685 12756 100 66     32541 if (defined $datetime_info{hour12}
686             && defined $datetime_info{ampm}) {
687 5868         6898 $datetime{hour} = $datetime_info{hour12};
688             $datetime{hour} += 12
689 5868 100 66     18082 if $datetime_info{ampm} == 2 && $datetime{hour} < 12;
690             }
691 12756 100       18068 if (defined $datetime_info{hour24}) {
692 8         10 $datetime{hour} = $datetime_info{hour24};
693 8 100       20 if ($datetime{hour} == 24) {
694 3         33 $datetime{hour} = 0;
695             }
696             }
697              
698             # Handle 24:00:00 time notations
699 12756 100       22921 if ($datetime{hour} == 24) {
700 3 100 66     24 if ($datetime{minute} == 0
      66        
701             && $datetime{second} == 0
702             && $datetime{nanosecond} == 0) {
703 2         3 $datetime{hour} = 0;
704 2         4 $datetime_info{dayadd} = 1;
705             } else {
706 1         10 return $self->_local_croak("Could not get datetime for $datetime_initial: Invalid 24-hour notation")
707             }
708             }
709              
710             # Handle era
711 12755 50 66     20749 if (defined $datetime_info{era}
      33        
712             && $datetime_info{era} == 0
713             && defined $datetime{year}) {
714 0         0 $datetime{year} *= -1;
715             }
716              
717             # Handle incomplete datetime information
718 12755 100 100     48428 unless (defined $datetime{year}
      100        
719             && defined $datetime{month}
720             && defined $datetime{day}) {
721              
722             # I want given/when in 5.8
723 2935 100       5789 if (ref $self->{incomplete} eq 'CODE') {
    100          
    50          
724 1         4 %datetime = &{$self->{incomplete}}($self,%datetime);
  1         3  
725             } elsif ($self->{incomplete} eq '1') {
726 2933   50     7598 $datetime{day} ||= 1;
727 2933   100     6323 $datetime{month} ||= 1;
728 2933   100     6724 $datetime{year} ||= 1;
729             } elsif ($self->{incomplete} eq 'incomplete') {
730 1         622 require DateTime::Incomplete;
731 1         40697 my $dt = eval {
732 1         11 return DateTime::Incomplete->new(%datetime);
733             };
734 1 50 33     50 return $self->_local_croak("Could not get datetime for $datetime_initial: $@")
735             if $@ || ref $dt ne 'DateTime::Incomplete';
736 1         12 return $dt;
737             } else {
738 0         0 return $self->_local_croak("Could not get datetime for $datetime_initial: Invalid incomplete setting");
739             }
740             }
741              
742             # Build datetime
743 12754         12399 my $dt = eval {
744 12754         51213 return DateTime->new(%datetime);
745             };
746 12754 100 66     3632308 return $self->_local_croak("Could not get datetime for $datetime_initial: $@")
747             if $@ || ref $dt ne 'DateTime';
748              
749             # Postprocessing
750 12751 100       20911 if ($datetime_info{dayadd}) {
751 2         10 $dt->add( days => 1 );
752             }
753              
754             # Perform checks
755 12751         24662 foreach my $check ( keys %datetime_check ) {
756 2278 100       5509 unless ($dt->$check == $datetime_check{$check}) {
757 2         18 return $self->_local_croak("Datetime '$check' does not match ('$datetime_check{$check}' vs. '".$dt->$check."') for '$datetime_initial'");
758             }
759             }
760              
761 12749         86821 return $dt;
762             }
763              
764             =head3 format_datetime
765              
766             my $string = $cldr->format_datetime($datetime);
767              
768             Formats a C<DateTime> object using the set locale and pattern. (not the
769             time_zone)
770              
771             =cut
772              
773             sub format_datetime {
774 12685     12685 1 12954031 my ( $self, $dt ) = @_;
775              
776 12685 50 33     92676 $dt = DateTime->now
      33        
777             unless defined $dt && ref $dt && $dt->isa('DateTime');
778              
779             #see http://rt.cpan.org/Public/Bug/Display.html?id=49605
780             #my ( $self, $dt ) = validate_pos( @_, 1, { default => DateTime->now, type => OBJECT } );
781 12685         25497 $dt = $dt->clone;
782 12685         111282 $dt->set_locale($self->{locale});
783              
784 12685         941100 return $dt->format_cldr($self->{pattern});
785             }
786              
787              
788             =head3 errmsg
789              
790             my $string = $cldr->errmsg();
791              
792             Stores the last error message. Especially useful if the on_error behavior of the
793             object is 'undef', so you can work out why things went wrong.
794              
795             =cut
796              
797             sub errmsg {
798 1     1 1 550 return $_[0]->{errmsg};
799             }
800              
801              
802             =head2 Exportable functions
803              
804             There are no methods exported by default, however the following are available:
805              
806             =head3 cldr_format
807              
808             use DateTime::Format::CLDR qw(cldr_format);
809             &cldr_format($pattern,$datetime);
810              
811             =cut
812              
813             sub cldr_format {
814 1     1 1 527 my ($pattern, $datetime) = @_;
815              
816 1         4 return $datetime->format_cldr($pattern);
817             }
818              
819             =head3 cldr_parse
820              
821             use DateTime::Format::CLDR qw(cldr_parse);
822             &cldr_parse($pattern,$string);
823             OR
824             &cldr_parse($pattern,$string,$locale);
825              
826             Default locale is 'en'.
827              
828             =cut
829              
830             sub cldr_parse {
831 1     1 1 949 my ($pattern, $string, $locale) = @_;
832              
833 1   50     3 $locale ||= 'en';
834 1         7 return DateTime::Format::CLDR->new(
835             pattern => $pattern,
836             locale => $locale,
837             on_error=>'croak',
838             )->parse_datetime($string);
839             }
840              
841              
842             # ---------------------------------------------------------------------------
843             # Private methods
844             # ---------------------------------------------------------------------------
845              
846             # Parse the pattern and return a data sctructure that can be easily used
847             # by parse_datetime
848              
849             sub _build_pattern {
850 12763     12763   11295 my ($self) = @_;
851              
852             # Return cached pattern
853             return $self->{_built_pattern}
854 12763 100       33713 if defined $self->{_built_pattern};
855              
856 112         159 $self->{_built_pattern} = [];
857              
858             # Try to parse pattern one element each time
859 112         579 while ($self->{pattern} =~ m/\G
860             (?:
861             '((?:[^']|'')*)' # quote escaped bit of text
862             # it needs to end with one
863             # quote not followed by
864             # another
865             |
866             (([a-zA-Z])\3*) # could be a pattern
867             |
868             (.) # anything else
869             )
870             /sxg) {
871 846         1186 my ($string,$pattern,$rest) = ($1,$2,$4);
872              
873              
874             # Found quoted string
875 846 100       1385 if ($string) {
    100          
    50          
876 10         17 $string =~ s/\'\'/\'/g;
877 10         10 push @{$self->{_built_pattern}}, _quotestring($string);
  10         33  
878              
879             # Found pattern
880             } elsif ($pattern) {
881             # Get length and command
882 469         357 my $length = length $pattern;
883 469         510 my $command = substr $pattern,0,1;
884 469         316 my ($rule,$regexp,$index);
885              
886             # Inflate 'j' pattern depending on locale
887 469 100       660 if ($command eq 'j') {
888 1 50       4 $command = ($self->{locale}->prefers_24_hour_time()) ? 'H':'h';
889             }
890              
891             # Find most appropriate command
892 469         693 for (my $count = $length; $count > 0; $count --) {
893 718 100       1446 if (defined $PARSER{$command.$count}) {
894 469         442 $rule = $PARSER{$command.$count};
895 469         348 $index = $count;
896 469         388 last;
897             }
898             }
899              
900 469 50       641 return $self->_local_croak("Broken pattern: $command $length")
901             unless $rule;
902              
903             # Pattern definition is regular expression
904 469 100       739 if (ref $rule eq 'Regexp') {
    100          
905             #$regexp = '0*'.$rule; # Match leading zeros
906 398         296 $regexp = $rule;
907              
908             # Pattern definition is array of possible values
909             } elsif (ref $rule eq 'ARRAY') {
910              
911 22         37 $regexp = _quoteslist($rule);
912             # Try to find matching element (long elements first)
913              
914             # Pattern definition is DateTime::Locale method (returning an array)
915             } else {
916 49         162 $regexp = _quoteslist($self->{locale}->$rule());
917             }
918              
919 469         567 push @{$self->{_built_pattern}},[$regexp,$command,$index];
  469         2159  
920              
921             # Found unqoted string
922             } elsif ($rest) {
923 367         253 push @{$self->{_built_pattern}}, _quotestring($rest);
  367         554  
924             }
925             }
926              
927 112         152 return $self->{_built_pattern};
928             }
929              
930             # Turn array into regexp
931              
932             sub _quoteslist {
933 71     71   173 my ($list) = @_;
934              
935             return
936             '('.
937             (join
938             '|',
939 7420         6041 map { _quotestring($_) }
940 71         75 sort { length $b <=> length $a } @{$list}
  36974         22160  
  71         576  
941             ).
942             ')';
943             }
944              
945             # Quote regexp
946              
947             sub _quotestring {
948 7797     7797   5409 my ($quote) = @_;
949              
950 7797         12881 $quote =~ s/([^[:alnum:][:space:]])/\\$1/g;
951 7797         6001 $quote =~ s/\s+/\\s+/g;
952 7797         9794 return $quote;
953             }
954              
955             # Error
956              
957             sub _local_croak {
958 13     13   23 my ($self,$message) = @_;
959              
960 13         19 $self->{errmsg} = $message;
961              
962 1         3 return &{$self->{on_error}}($self,$message,@_)
963 13 100       30 if ref($self->{on_error}) eq 'CODE';
964              
965             croak($message)
966 12 100       263 if $self->{on_error} eq 'croak';
967              
968             return undef
969 4 50       35 if ($self->{on_error} eq 'undef');
970              
971 0         0 return;
972             }
973              
974             # Warning
975              
976             sub _local_carp {
977 2     2   3 my ($self,$message) = @_;
978              
979 2         3 $self->{errmsg} = $message;
980              
981 0         0 return &{$self->{on_error}}($self,$message,@_)
982 2 50       8 if ref($self->{on_error}) eq 'CODE';
983              
984             carp($message)
985 2 50       41 if $self->{on_error} eq 'croak';
986              
987             return undef
988 2 50       801 if ($self->{on_error} eq 'undef');
989              
990 2         3 return;
991             }
992              
993              
994              
995              
996             1;
997              
998             =head1 CLDR PATTERNS
999              
1000             =head2 Parsing
1001              
1002             Some patterns like day of week, quarter, ect. cannot be used to construct
1003             a date. However these patterns can be parsed, and a warning will be
1004             issued if they do not match the parsed date.
1005              
1006             Ambigous patterns (eg. narrow day of week formats for many locales) will
1007             be parsed but ignored in datetime calculation.
1008              
1009             =head2 Supported CLDR Patterns
1010              
1011             See L<DateTime/"CLDR Patterns">.
1012              
1013             CLDR provides the following patterns:
1014              
1015             =over 4
1016              
1017             =item * G{1,3}
1018              
1019             The abbreviated era (BC, AD).
1020              
1021             =item * GGGG
1022              
1023             The wide era (Before Christ, Anno Domini).
1024              
1025             =item * GGGGG
1026              
1027             The narrow era, if it exists (and it mostly doesn't).
1028              
1029             Not used to construct a date.
1030              
1031             =item * y and y{3,}
1032              
1033             The year, zero-prefixed as needed.
1034              
1035             =item * yy
1036              
1037             This is a special case. It always produces a two-digit year, so "1976"
1038             becomes "76".
1039              
1040             =item * Y{1,}
1041              
1042             The week of the year, from C<< $dt->week_year() >>.
1043              
1044             =item * u{1,}
1045              
1046             Same as "y" except that "uu" is not a special case.
1047              
1048             =item * Q{1,2}
1049              
1050             The quarter as a number (1..4).
1051              
1052             Not used to construct a date.
1053              
1054             =item * QQQ
1055              
1056             The abbreviated format form for the quarter.
1057              
1058             Not used to construct a date.
1059              
1060             =item * QQQQ
1061              
1062             The wide format form for the quarter.
1063              
1064             Not used to construct a date.
1065              
1066             =item * q{1,2}
1067              
1068             The quarter as a number (1..4).
1069              
1070             Not used to construct a date.
1071              
1072             =item * qqq
1073              
1074             The abbreviated stand-alone form for the quarter.
1075              
1076             Not used to construct a date.
1077              
1078             =item * qqqq
1079              
1080             The wide stand-alone form for the quarter.
1081              
1082             Not used to construct a date.
1083              
1084             =item * M{1,2}
1085              
1086             The numerical month.
1087              
1088             =item * MMM
1089              
1090             The abbreviated format form for the month.
1091              
1092             =item * MMMM
1093              
1094             The wide format form for the month.
1095              
1096             =item * MMMMM
1097              
1098             The narrow format form for the month.
1099              
1100             =item * L{1,2}
1101              
1102             The numerical month.
1103              
1104             =item * LLL
1105              
1106             The abbreviated stand-alone form for the month.
1107              
1108             =item * LLLL
1109              
1110             The wide stand-alone form for the month.
1111              
1112             =item * LLLLL
1113              
1114             The narrow stand-alone form for the month.
1115              
1116             =item * w{1,2}
1117              
1118             The week of the year, from C<< $dt->week_number() >>.
1119              
1120             Not used to construct a date.
1121              
1122             =item * W
1123              
1124             The week of the month, from C<< $dt->week_of_month() >>.
1125              
1126             Not used to construct a date.
1127              
1128             =item * d{1,2}
1129              
1130             The numeric day of of the month.
1131              
1132             =item * D{1,3}
1133              
1134             The numeric day of of the year.
1135              
1136             Not used to construct a date.
1137              
1138             =item * F
1139              
1140             The day of the week in the month, from C<< $dt->weekday_of_month() >>.
1141              
1142             Not used to construct a date.
1143              
1144             =item * g{1,}
1145              
1146             The modified Julian day, from C<< $dt->mjd() >>.
1147              
1148             Not supported by DateTime::Format::CLDR
1149              
1150             =item * E{1,3}
1151              
1152             The abbreviated format form for the day of the week.
1153              
1154             Not used to construct a date.
1155              
1156             =item * EEEE
1157              
1158             The wide format form for the day of the week.
1159              
1160             Not used to construct a date.
1161              
1162             =item * EEEEE
1163              
1164             The narrow format form for the day of the week.
1165              
1166             Not used to construct a date.
1167              
1168             =item * e{1,2}
1169              
1170             The I<local> day of the week, from 1 to 7. This number depends on what
1171             day is considered the first day of the week, which varies by
1172             locale. For example, in the US, Sunday is the first day of the week,
1173             so this returns 2 for Monday.
1174              
1175             Not used to construct a date.
1176              
1177             =item * eee
1178              
1179             The abbreviated format form for the day of the week.
1180              
1181             Not used to construct a date.
1182              
1183             =item * eeee
1184              
1185             The wide format form for the day of the week.
1186              
1187             Not used to construct a date.
1188              
1189             =item * eeeee
1190              
1191             The narrow format form for the day of the week.
1192              
1193             Not used to construct a date.
1194              
1195             =item * c
1196              
1197             The numeric day of the week (not localized).
1198              
1199             Not used to construct a date.
1200              
1201             =item * ccc
1202              
1203             The abbreviated stand-alone form for the day of the week.
1204              
1205             Not used to construct a date.
1206              
1207             =item * cccc
1208              
1209             The wide stand-alone form for the day of the week.
1210              
1211             Not used to construct a date.
1212              
1213             =item * ccccc
1214              
1215             The narrow format form for the day of the week.
1216              
1217             Not used to construct a date.
1218              
1219             =item * a
1220              
1221             The localized form of AM or PM for the time.
1222              
1223             =item * h{1,2}
1224              
1225             The hour from 1-12.
1226              
1227             =item * H{1,2}
1228              
1229             The hour from 0-23.
1230              
1231             =item * K{1,2}
1232              
1233             The hour from 0-11.
1234              
1235             =item * k{1,2}
1236              
1237             The hour from 1-24. Note that hour 24 is equivalent to midnight on the date
1238             being parsed, not midnight of the next day.
1239              
1240             =item * j{1,2}
1241              
1242             The hour, in 12 or 24 hour form, based on the preferred form for the
1243             locale. In other words, this is equivalent to either "h{1,2}" or
1244             "H{1,2}".
1245              
1246             =item * m{1,2}
1247              
1248             The minute.
1249              
1250             =item * s{1,2}
1251              
1252             The second.
1253              
1254             =item * S{1,}
1255              
1256             The fractional portion of the seconds, rounded based on the length of the
1257             specifier. This returned without a leading decimal point, but may have
1258             leading or trailing zeroes.
1259              
1260             =item * A{1,}
1261              
1262             The millisecond of the day, based on the current time. In other words, if it
1263             is 12:00:00.00, this returns 43200000.
1264              
1265             Not supported by DateTime::Format::CLDR
1266              
1267             =item * z{1,3}
1268              
1269             The time zone short name.
1270              
1271             =item * zzzz
1272              
1273             The time zone long name.
1274              
1275             =item * Z{1,3}
1276              
1277             The time zone offset.
1278              
1279             =item * ZZZZ
1280              
1281             The time zone short name and the offset as one string, so something like
1282             "CDT-0500".
1283              
1284             =item * v{1,3}
1285              
1286             The time zone short name.
1287              
1288             =item * vvvv
1289              
1290             The time zone long name.
1291              
1292             =item * V{1,3}
1293              
1294             The time zone short name.
1295              
1296             =item * VVVV
1297              
1298             The time zone long name.
1299              
1300             =back
1301              
1302             =head1 CAVEATS
1303              
1304             Patterns without separators (like 'dMy' or 'yMd') are ambigous for some
1305             dates and might fail.
1306              
1307             Quote from the Author of C<DateTime::Format::Strptime> which also applies to
1308             this module:
1309              
1310             "If your module uses this module to parse a known format: stop it. This module
1311             is clunky and slow because it can parse almost anything. Parsing a known
1312             format is not so difficult, is it? You'll make your module faster if you do.
1313             And you're not left at the whim of my potentially broken code."
1314              
1315             =head1 SUPPORT
1316              
1317             Please report any bugs or feature requests to
1318             C<datetime-format-cldr@rt.cpan.org>, or through the web interface at
1319             L<http://rt.cpan.org/Public/Bug/Report.html?Queue=DateTime::Format::CLDR>.
1320             I will be notified and then you'll automatically be notified of the progress
1321             on your report as I make changes.
1322              
1323             =head1 SEE ALSO
1324              
1325             datetime@perl.org mailing list
1326              
1327             L<http://datetime.perl.org/>
1328              
1329             L<DateTime>, L<DateTime::Locale>, L<DateTime::TimeZone>
1330             and L<DateTime::Format::Strptime>
1331              
1332             =head1 AUTHOR
1333              
1334             MaroÅ¡ Kollár
1335             CPAN ID: MAROS
1336             maros [at] k-1.com
1337              
1338             http://www.k-1.com
1339              
1340             =head1 COPYRIGHT
1341              
1342             DateTime::Format::CLDR is Copyright (c) 2008-2012 MaroÅ¡ Kollár
1343             - L<http://www.k-1.com>
1344              
1345             =head1 LICENCE
1346              
1347             This library is free software, you can redistribute it and/or modify
1348             it under the same terms as Perl itself.
1349              
1350             =cut