| 1 | package DateTime::Format::Flexible::lang::de; | ||
| 2 | |||
| 3 | 20 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 20 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | sub new | ||
| 7 | { | ||
| 8 | 0 | ▶ | my ( $class , %params ) = @_; |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 9 | 0 | my $self = bless \%params , $class; | |
| 10 | 0 | return $self; | |
| 11 | } | ||
| 12 | |||
| 13 | sub months | ||
| 14 | { | ||
| 15 | return ( | ||
| 16 | 7252 | ▶ | qr{Jan(?:uar)?}i => 1, |
|
Subroutine
months: called CC=1 SCAR=0.0
Pod
documented
| |||
| 17 | qr{Jän(?:er)?}i => 1, # Austrian?! | ||
| 18 | qr{Feb(?:ruar)?}i => 2, | ||
| 19 | qr{Mär(?:z)?|Maerz}i => 3, | ||
| 20 | qr{Apr(?:il)?}i => 4, | ||
| 21 | qr{Mai}i => 5, | ||
| 22 | qr{Jun(?:i)?}i => 6, | ||
| 23 | qr{Jul(?:i)?}i => 7, | ||
| 24 | qr{Aug(?:ust)?}i => 8, | ||
| 25 | qr{Sep(?:tember)?}i => 9, | ||
| 26 | qr{Okt(?:ober)?}i => 10, | ||
| 27 | qr{Nov(?:ember)?}i => 11, | ||
| 28 | qr{Dez(?:ember)?}i => 12, | ||
| 29 | ); | ||
| 30 | } | ||
| 31 | |||
| 32 | sub days | ||
| 33 | { | ||
| 34 | return [ | ||
| 35 | 7252 | ▶ | {Montag => 1}, # Monday |
|
Subroutine
days: called CC=1 SCAR=0.0
Pod
documented
| |||
| 36 | {Mo => 1}, # Monday | ||
| 37 | {Dienstag => 2}, # Tuesday | ||
| 38 | {Di => 2}, # Tuesday | ||
| 39 | {Mittwoch => 3}, # Wednesday | ||
| 40 | {Mi => 3}, # Wednesday | ||
| 41 | {Donnerstag => 4}, # Thursday | ||
| 42 | {Do => 4}, # Thursday | ||
| 43 | {Freitag => 5}, # Friday | ||
| 44 | {Fr => 5}, # Friday | ||
| 45 | {Samstag => 6}, # Saturday | ||
| 46 | {Sa => 6}, # Saturday | ||
| 47 | {Sonnabend => 6}, # Saturday | ||
| 48 | {Sonntag => 7}, # Sunday | ||
| 49 | {So => 7}, # Sunday | ||
| 50 | ]; | ||
| 51 | } | ||
| 52 | |||
| 53 | sub day_numbers | ||
| 54 | { | ||
| 55 | return ( | ||
| 56 | 3626 | ▶ | q{erster} => 1, # first |
|
Subroutine
day_numbers: called CC=1 SCAR=0.0
Pod
documented
| |||
| 57 | q{ersten} => 1, # first | ||
| 58 | q{zweiter} => 2, # second | ||
| 59 | q{dritter} => 3, # third | ||
| 60 | q{vierter} => 4, # fourth | ||
| 61 | q{fünfter} => 5, # fifth | ||
| 62 | q{fuenfter} => 5, # fifth | ||
| 63 | q{sechster} => 6, # sixth | ||
| 64 | q{siebter} => 7, # seventh | ||
| 65 | q{achter} => 8, # eighth | ||
| 66 | q{neunter} => 9, # ninth | ||
| 67 | q{zehnter} => 10, # tenth | ||
| 68 | q{elfter} => 11, # eleventh | ||
| 69 | q{zwölfter} => 12, # twelfth | ||
| 70 | q{zwoelfter} => 12, # twelfth | ||
| 71 | q{dreizehnter} => 13, # thirteenth | ||
| 72 | q{vierzehnter} => 14, # fourteenth | ||
| 73 | q{vierzehnten} => 14, # fourteenth | ||
| 74 | q{fünfzehnter} => 15, # fifteenth | ||
| 75 | q{fuenfzehnter} => 15, # fifteenth | ||
| 76 | q{sechzehnter} => 16, # sixteenth | ||
| 77 | q{siebzehnter} => 17, # seventeenth | ||
| 78 | q{achtzehnter} => 18, # eithteenth | ||
| 79 | q{neunzehnter} => 19, # ninteenth | ||
| 80 | q{zwanzigster} => 20, # twentieth | ||
| 81 | q{einundzwanzigster} => 21, # twenty first | ||
| 82 | q{zweiundzwanzigster} => 22, # twenty second | ||
| 83 | q{dreiundzwanzigster} => 23, # twenty third | ||
| 84 | q{vierundzwanzigster} => 24, # twenty fourth | ||
| 85 | q{fünfundzwanzigster} => 25, # twenty fifth | ||
| 86 | q{fuenfundzwanzigster} => 25, # twenty fifth | ||
| 87 | q{sechsundzwanzigster} => 26, # twenty sixth | ||
| 88 | q{siebenundzwanzigster} => 27, # twenty seventh | ||
| 89 | q{achtundzwanzigster} => 28, # twenty eighth | ||
| 90 | q{neunundzwanzigster} => 29, # twenty ninth | ||
| 91 | q{dreißigster} => 30, # thirtieth | ||
| 92 | q{dreissigster} => 30, # thirtieth | ||
| 93 | q{einunddreißigster} => 31, # thirty first | ||
| 94 | q{einunddreissigster} => 31, # thirty first | ||
| 95 | ); | ||
| 96 | } | ||
| 97 | |||
| 98 | sub hours | ||
| 99 | { | ||
| 100 | return ( | ||
| 101 | 3626 | ▶ | Mittag => '12:00:00', # noon |
|
Subroutine
hours: called CC=1 SCAR=0.0
Pod
documented
| |||
| 102 | mittags => '12:00:00', # noon | ||
| 103 | Mitternacht => '00:00:00', # midnight | ||
| 104 | mitternachts => '00:00:00', # midnight | ||
| 105 | ); | ||
| 106 | } | ||
| 107 | |||
| 108 | sub remove_strings | ||
| 109 | { | ||
| 110 | return ( | ||
| 111 | # we want to remove ' am ' only when it does not follow a digit | ||
| 112 | # we also don't want to remove am when it follows a capital T, | ||
| 113 | # we can have a capital T when we have already determined the time | ||
| 114 | # part of a string | ||
| 115 | # if we just remove ' am ', it removes am/pm designation, losing accuracy | ||
| 116 | 3626 | ▶ | qr{(?<!\d|T)\sam\b}i, # remove ' am ' as in '20. Feb am Mittag' |
|
Subroutine
remove_strings: called CC=1 SCAR=0.0
Pod
documented
| |||
| 117 | # we can also remove it if it is at the beginning | ||
| 118 | qr{\A\bam\b}i, | ||
| 119 | qr{\bum\b}i, # remove ' um ' as in '20. Feb um Mitternacht' | ||
| 120 | ); | ||
| 121 | } | ||
| 122 | |||
| 123 | sub parse_time | ||
| 124 | { | ||
| 125 | 3626 | ▶ | my ( $self, $date ) = @_; |
|
Subroutine
parse_time: called CC=1 SCAR=0.0
Pod
documented
| |||
| 126 | 3626 | return $date; | |
| 127 | } | ||
| 128 | |||
| 129 | sub string_dates | ||
| 130 | { | ||
| 131 | 3626 | ▶ | my $base_dt = DateTime::Format::Flexible->base; |
|
Subroutine
string_dates: called CC=1 SCAR=3.3
Pod
documented
| |||
| 132 | return ( | ||
| 133 | 0 | ▶ | jetzt => sub { return $base_dt->datetime }, # now |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 134 | 0 | ▶ | heute => sub { return $base_dt->clone->truncate( to => 'day' )->ymd } , # today |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 135 | 0 | ▶ | morgen => sub { return $base_dt->clone->truncate( to => 'day' )->add( days => 1 )->ymd }, # tomorrow |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 136 | 0 | ▶ | gestern => sub { return $base_dt->clone->truncate( to => 'day' )->subtract( days => 1 )->ymd }, # yesterday |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 137 | 0 | ▶ | 'übermorgen' => sub { return DateTime->today->add( days => 2 )->ymd }, # overmorrow (the day after tomorrow) don't know if the Umlaut works |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 138 | 0 | ▶ | uebermorgen => sub { return DateTime->today->add( days => 2 )->ymd }, # overmorrow (the day after tomorrow) |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 139 | 0 | ▶ | Epoche => sub { return DateTime->from_epoch( epoch => 0 ) }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 140 | 0 | ▶ | '-unendlich' => sub { return '-infinity' }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 141 | 2 | ▶ | unendlich => sub { return 'infinity' }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 142 | 3626 | ); | |
| 143 | } | ||
| 144 | |||
| 145 | sub relative | ||
| 146 | { | ||
| 147 | return ( | ||
| 148 | # as in 3 years ago, -3 years | ||
| 149 | 3626 | ▶ | ago => qr{\bvor\b|\A\-}i, |
|
Subroutine
relative: called CC=1 SCAR=0.0
Pod
documented
| |||
| 150 | # as in 3 years from now, +3 years | ||
| 151 | from => qr{\bab\b\s\bjetzt\b|\A\+}i, | ||
| 152 | # as in next Monday | ||
| 153 | next => qr{\bnächste|nachste\b}i, | ||
| 154 | # as in last Monday | ||
| 155 | last => qr{\bletzten\b}i, | ||
| 156 | ); | ||
| 157 | } | ||
| 158 | |||
| 159 | sub math_strings | ||
| 160 | { | ||
| 161 | return ( | ||
| 162 | 4 | ▶ | Jahr => 'years' , |
|
Subroutine
math_strings: called CC=1 SCAR=0.0
Pod
documented
| |||
| 163 | Jahre => 'years' , | ||
| 164 | Jahren => 'years' , | ||
| 165 | Monat => 'months' , | ||
| 166 | Monate => 'months' , | ||
| 167 | Tag => 'days' , | ||
| 168 | Tage => 'days' , | ||
| 169 | Stunde => 'hours' , | ||
| 170 | Stunden => 'hours' , | ||
| 171 | Minute => 'minutes' , | ||
| 172 | Minuten => 'minutes' , | ||
| 173 | Woche => 'weeks', | ||
| 174 | Wochen => 'weeks', | ||
| 175 | ); | ||
| 176 | } | ||
| 177 | |||
| 178 | sub timezone_map | ||
| 179 | { | ||
| 180 | # http://home.tiscali.nl/~t876506/TZworld.html | ||
| 181 | return ( | ||
| 182 | 3626 | ▶ | CET => 'Europe/Berlin', |
|
Subroutine
timezone_map: called CC=1 SCAR=0.0
Pod
documented
| |||
| 183 | CEST => 'Europe/Berlin', | ||
| 184 | MEZ => 'Europe/Berlin', # German Version: Mitteleuropäische Zeit | ||
| 185 | MESZ => 'Europe/Berlin', # Mitteleuropäische Sommerzeit | ||
| 186 | ); | ||
| 187 | } | ||
| 188 | |||
| 189 | 20 | 1; | |
| 190 | __END__ | ||
| 191 | |||
| 192 | =encoding utf-8 | ||
| 193 | |||
| 194 | =head1 NAME | ||
| 195 | |||
| 196 | DateTime::Format::Flexible::lang::de - german language plugin | ||
| 197 | |||
| 198 | =head1 DESCRIPTION | ||
| 199 | |||
| 200 | You should not need to use this module directly. | ||
| 201 | |||
| 202 | If you only want to use one language, specify the lang property when parsing a date. | ||
| 203 | |||
| 204 | example: | ||
| 205 | |||
| 206 | my $dt = DateTime::Format::Flexible->parse_datetime( | ||
| 207 | 'Montag, 6. Dez 2010' , | ||
| 208 | lang => ['de'] | ||
| 209 | ); | ||
| 210 | # $dt is now 2010-12-06T00:00:00 | ||
| 211 | |||
| 212 | Note that this is not required, by default ALL languages are scanned when trying to parse a date. | ||
| 213 | |||
| 214 | =head2 new | ||
| 215 | |||
| 216 | Instantiate a new instance of this module. | ||
| 217 | |||
| 218 | =head2 months | ||
| 219 | |||
| 220 | month name regular expressions along with the month numbers (Jan(:?uar)? => 1) | ||
| 221 | |||
| 222 | =head2 days | ||
| 223 | |||
| 224 | day name regular expressions along the the day numbers (Montag => 1) | ||
| 225 | |||
| 226 | =head2 day_numbers | ||
| 227 | |||
| 228 | maps day of month names to the corresponding numbers (erster => 01) | ||
| 229 | |||
| 230 | =head2 hours | ||
| 231 | |||
| 232 | maps hour names to numbers (Mittag => 12:00:00) | ||
| 233 | |||
| 234 | =head2 remove_strings | ||
| 235 | |||
| 236 | strings to remove from the date (um as in um Mitternacht) | ||
| 237 | |||
| 238 | =head2 parse_time | ||
| 239 | |||
| 240 | currently does nothing | ||
| 241 | |||
| 242 | =head2 string_dates | ||
| 243 | |||
| 244 | maps string names to real dates (jetzt => DateTime->now) | ||
| 245 | |||
| 246 | =head2 relative | ||
| 247 | |||
| 248 | parse relative dates (ago => vor, from => a jetzt, next => nachste, last => letzten) | ||
| 249 | |||
| 250 | =head2 math_strings | ||
| 251 | |||
| 252 | useful strings when doing datetime math | ||
| 253 | |||
| 254 | =head2 timezone_map | ||
| 255 | |||
| 256 | maps unofficial timezones to official timezones for this language (MEZ => Europe/Berlin) | ||
| 257 | |||
| 258 | =head1 AUTHOR | ||
| 259 | |||
| 260 | Mark Trettin <nulldevice.mark@gmx.de> | ||
| 261 | |||
| 262 | Based on DateTime::Format::Flexible::lang::en by | ||
| 263 | Tom Heady | ||
| 264 | CPAN ID: thinc | ||
| 265 | Punch, Inc. | ||
| 266 | cpan@punch.net | ||
| 267 | http://www.punch.net/ | ||
| 268 | |||
| 269 | =head1 COPYRIGHT & LICENSE | ||
| 270 | |||
| 271 | Copyright 2011 Mark Trettin. | ||
| 272 | |||
| 273 | This program is free software; you can redistribute it and/or | ||
| 274 | modify it under the terms of either: | ||
| 275 | |||
| 276 | =over 4 | ||
| 277 | |||
| 278 | =item * the GNU General Public License as published by the Free | ||
| 279 | Software Foundation; either version 1, or (at your option) any | ||
| 280 | later version, or | ||
| 281 | |||
| 282 | =item * the Artistic License version. | ||
| 283 | |||
| 284 | =back | ||
| 285 | |||
| 286 | =head1 SEE ALSO | ||
| 287 | |||
| 288 | F<DateTime::Format::Flexible> | ||
| 289 | |||
| 290 | =cut | ||
| 291 | ### Local variables: | ||
| 292 | ### coding: utf-8 | ||
| 293 | ### End: | ||