| 1 |
#!/usr/bin/perl -w |
| 2 |
# Copyright (c) 2012-2026 Sullivan Beck. All rights reserved. |
| 3 |
# This program is free software; you can redistribute it and/or modify it |
| 4 |
# under the same terms as Perl itself. |
| 5 |
|
| 6 |
############################################################################### |
| 7 |
############################################################################### |
| 8 |
# This script is used to automatically generate the language pod files. |
| 9 |
|
| 10 |
use lib "./lib"; |
| 11 |
|
| 12 |
require 5.010000; |
| 13 |
use IO::File; |
| 14 |
use strict; |
| 15 |
use warnings; |
| 16 |
require Date::Manip::Lang::index; |
| 17 |
$| = 1; |
| 18 |
|
| 19 |
our $VERSION; |
| 20 |
$VERSION='6.99'; |
| 21 |
|
| 22 |
############################################################################## |
| 23 |
# GLOBAL VARIABLES |
| 24 |
############################################################################### |
| 25 |
|
| 26 |
our $langdir = 'lib/Date/Manip/Lang'; |
| 27 |
our $curry = ( localtime(time) )[5] + 1900; |
| 28 |
|
| 29 |
############################################################################### |
| 30 |
# HELP |
| 31 |
############################################################################### |
| 32 |
|
| 33 |
our ($usage); |
| 34 |
my $COM = $0; |
| 35 |
$COM =~ s/^.*\///; |
| 36 |
|
| 37 |
$usage= |
| 38 |
"usage: $COM OPTIONS |
| 39 |
-h/--help : Print help. |
| 40 |
|
| 41 |
This script will generate the pod files for each of the Date::Manip |
| 42 |
language modules. |
| 43 |
"; |
| 44 |
|
| 45 |
############################################################################### |
| 46 |
# PARSE ARGUMENTS |
| 47 |
############################################################################### |
| 48 |
|
| 49 |
while ($_ = shift) { |
| 50 |
(print $usage), exit if ($_ eq "-h" || $_ eq "--help"); |
| 51 |
} |
| 52 |
|
| 53 |
############################################################################ |
| 54 |
# MAIN PROGRAM |
| 55 |
############################################################################ |
| 56 |
|
| 57 |
no warnings; |
| 58 |
my @mod = values %Date::Manip::Lang::index::Lang; |
| 59 |
use warnings; |
| 60 |
|
| 61 |
my %mod = map { $_,1 } @mod; |
| 62 |
@mod = sort keys %mod; |
| 63 |
|
| 64 |
foreach my $mod (@mod) { |
| 65 |
write_pod($mod); |
| 66 |
} |
| 67 |
|
| 68 |
############################################################################ |
| 69 |
############################################################################ |
| 70 |
|
| 71 |
no strict 'refs'; |
| 72 |
sub write_pod { |
| 73 |
my($mod) = @_; |
| 74 |
|
| 75 |
my $undef = " Not defined in this language\n"; |
| 76 |
eval "require Date::Manip::Lang::${mod}"; |
| 77 |
my $lang = ${ "Date::Manip::Lang::${mod}::Language" }; |
| 78 |
my $name = ${ "Date::Manip::Lang::${mod}::LangName" }; |
| 79 |
my $year0 = ${ "Date::Manip::Lang::${mod}::YearAdded" }; |
| 80 |
|
| 81 |
my $out = new IO::File; |
| 82 |
$out->open("> ${langdir}/${mod}.pod"); |
| 83 |
binmode $out, ":encoding(UTF-8)"; |
| 84 |
|
| 85 |
my %words; |
| 86 |
|
| 87 |
my %lists = ('ampm' => 2, |
| 88 |
'day_name' => 7, |
| 89 |
'day_abb' => 7, |
| 90 |
'day_char' => 7, |
| 91 |
'month_name' => 12, |
| 92 |
'month_abb' => 12, |
| 93 |
'fields' => 7, |
| 94 |
'nextprev' => 2, |
| 95 |
'nth' => 53, |
| 96 |
'mode' => 2, |
| 97 |
'when' => 2, |
| 98 |
); |
| 99 |
while (my($key,$num) = each %lists) { |
| 100 |
if (exists $$lang{$key}) { |
| 101 |
foreach (my $i=0; $i < $num; $i++) { |
| 102 |
$words{$key}[$i] = ''; |
| 103 |
if (defined ($$lang{$key}[$i])) { |
| 104 |
my @tmp = @{ $$lang{$key}[$i] }; |
| 105 |
foreach my $tmp (@tmp) { |
| 106 |
$words{$key}[$i] .= " $tmp\n" if ($tmp); |
| 107 |
} |
| 108 |
} else { |
| 109 |
print "Undefined: $mod,$key\n"; |
| 110 |
} |
| 111 |
$words{$key}[$i] = $undef if (! $words{$key}[$i]); |
| 112 |
} |
| 113 |
} else { |
| 114 |
foreach (my $i=0; $i < $num; $i++) { |
| 115 |
$words{$key}[$i] = $undef; |
| 116 |
} |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
my @words = qw(at each last of on); |
| 121 |
|
| 122 |
foreach my $set (@words) { |
| 123 |
$words{$set} = ''; |
| 124 |
if (exists $$lang{$set}) { |
| 125 |
my @tmp = @{ $$lang{$set} }; |
| 126 |
foreach my $tmp (@tmp) { |
| 127 |
$words{$set} .= " $tmp\n" if ($tmp); |
| 128 |
} |
| 129 |
} |
| 130 |
$words{$set} = $undef if (! $words{$set}); |
| 131 |
} |
| 132 |
|
| 133 |
@words = qw(offset_date offset_time times); |
| 134 |
|
| 135 |
foreach my $set (@words) { |
| 136 |
$words{$set} = ''; |
| 137 |
if (exists $$lang{$set}) { |
| 138 |
foreach my $key (sort keys %{ $$lang{$set} }) { |
| 139 |
my $val = $$lang{$set}{$key}; |
| 140 |
$words{$set} .= " $key" . " "x(20-length($key)) . " $val\n"; |
| 141 |
} |
| 142 |
} |
| 143 |
$words{$set} = $undef if (! $words{$set}); |
| 144 |
} |
| 145 |
|
| 146 |
if (exists $$lang{"sephm"}) { |
| 147 |
$words{"seps"} = ''; |
| 148 |
my @hm = @{ $$lang{"sephm"} }; |
| 149 |
my @ms = @{ $$lang{"sepms"} }; |
| 150 |
for (my $i=0; $i <= $#hm; $i++) { |
| 151 |
$words{'seps'} .= " $hm[$i] $ms[$i]\n"; |
| 152 |
} |
| 153 |
} else { |
| 154 |
$words{'seps'} = $undef; |
| 155 |
} |
| 156 |
|
| 157 |
if (exists $$lang{"sepfr"}) { |
| 158 |
$words{"sepfr"} = $$lang{"sepfr"}; |
| 159 |
} else { |
| 160 |
$words{'sepfr'} = $undef; |
| 161 |
} |
| 162 |
|
| 163 |
# Try to hide pod so it doesn't get indexed |
| 164 |
my $e = '='; |
| 165 |
|
| 166 |
print $out <<"EOF"; |
| 167 |
# Copyright (c) $year0-$curry Sullivan Beck. All rights reserved. |
| 168 |
# This program is free software; you can redistribute it and/or modify it |
| 169 |
# under the same terms as Perl itself. |
| 170 |
|
| 171 |
######################################################################## |
| 172 |
######################################################################## |
| 173 |
|
| 174 |
${e}pod |
| 175 |
|
| 176 |
${e}encoding utf-8 |
| 177 |
|
| 178 |
${e}head1 NAME |
| 179 |
|
| 180 |
Date::Manip::Lang::${mod} - ${name} language support. |
| 181 |
|
| 182 |
${e}head1 SYNOPSIS |
| 183 |
|
| 184 |
This module contains a list of words and expressions supporting |
| 185 |
the language. It is not intended to be used directly (other |
| 186 |
Date::Manip modules will load it as needed). |
| 187 |
|
| 188 |
${e}head1 LANGUAGE EXPRESSIONS |
| 189 |
|
| 190 |
The following is a list of all language words and expressions used |
| 191 |
to write times and/or dates. |
| 192 |
|
| 193 |
All strings are case insensitive. |
| 194 |
|
| 195 |
${e}over 4 |
| 196 |
|
| 197 |
${e}item B<Month names and abbreviations> |
| 198 |
|
| 199 |
When writing out the name of the month, several different variations may |
| 200 |
exist including full names and abbreviations. |
| 201 |
|
| 202 |
The following month names may be used: |
| 203 |
|
| 204 |
$words{month_name}[0] |
| 205 |
$words{month_name}[1] |
| 206 |
$words{month_name}[2] |
| 207 |
$words{month_name}[3] |
| 208 |
$words{month_name}[4] |
| 209 |
$words{month_name}[5] |
| 210 |
$words{month_name}[6] |
| 211 |
$words{month_name}[7] |
| 212 |
$words{month_name}[8] |
| 213 |
$words{month_name}[9] |
| 214 |
$words{month_name}[10] |
| 215 |
$words{month_name}[11] |
| 216 |
|
| 217 |
The following abbreviations may be used: |
| 218 |
|
| 219 |
$words{month_abb}[0] |
| 220 |
$words{month_abb}[1] |
| 221 |
$words{month_abb}[2] |
| 222 |
$words{month_abb}[3] |
| 223 |
$words{month_abb}[4] |
| 224 |
$words{month_abb}[5] |
| 225 |
$words{month_abb}[6] |
| 226 |
$words{month_abb}[7] |
| 227 |
$words{month_abb}[8] |
| 228 |
$words{month_abb}[9] |
| 229 |
$words{month_abb}[10] |
| 230 |
$words{month_abb}[11] |
| 231 |
|
| 232 |
${e}item B<Day names and abbreviations> |
| 233 |
|
| 234 |
When writing out the name of the day, several different variations may |
| 235 |
exist including full names and abbreviations. |
| 236 |
|
| 237 |
The following day names may be used: |
| 238 |
|
| 239 |
$words{day_name}[0] |
| 240 |
$words{day_name}[1] |
| 241 |
$words{day_name}[2] |
| 242 |
$words{day_name}[3] |
| 243 |
$words{day_name}[4] |
| 244 |
$words{day_name}[5] |
| 245 |
$words{day_name}[6] |
| 246 |
|
| 247 |
The following abbreviations may be used: |
| 248 |
|
| 249 |
$words{day_abb}[0] |
| 250 |
$words{day_abb}[1] |
| 251 |
$words{day_abb}[2] |
| 252 |
$words{day_abb}[3] |
| 253 |
$words{day_abb}[4] |
| 254 |
$words{day_abb}[5] |
| 255 |
$words{day_abb}[6] |
| 256 |
|
| 257 |
The following short (1-2 characters) abbreviations may be used: |
| 258 |
|
| 259 |
$words{day_char}[0] |
| 260 |
$words{day_char}[1] |
| 261 |
$words{day_char}[2] |
| 262 |
$words{day_char}[3] |
| 263 |
$words{day_char}[4] |
| 264 |
$words{day_char}[5] |
| 265 |
$words{day_char}[6] |
| 266 |
|
| 267 |
${e}item B<Delta field names> |
| 268 |
|
| 269 |
These are the names (and abbreviations) for the fields in a delta. There are |
| 270 |
7 fields: years, months, weeks, days, hours, minutes, seconds. |
| 271 |
|
| 272 |
The names and abbreviations for these fields are: |
| 273 |
|
| 274 |
$words{fields}[0] |
| 275 |
$words{fields}[1] |
| 276 |
$words{fields}[2] |
| 277 |
$words{fields}[3] |
| 278 |
$words{fields}[4] |
| 279 |
$words{fields}[5] |
| 280 |
$words{fields}[6] |
| 281 |
|
| 282 |
${e}item B<Morning/afternoon times> |
| 283 |
|
| 284 |
This is a list of expressions use to designate morning or afternoon time |
| 285 |
when a time is entered as a 12-hour time rather than a 24-hour time. |
| 286 |
For example, in English, the time "17:00" could be specified as "5:00 PM". |
| 287 |
|
| 288 |
Morning and afternoon time may be designated by the following sets of |
| 289 |
words: |
| 290 |
|
| 291 |
$words{ampm}[0] |
| 292 |
$words{ampm}[1] |
| 293 |
|
| 294 |
${e}item B<Each or every> |
| 295 |
|
| 296 |
There are a list of words that specify every occurrence of something. These |
| 297 |
are used in the following phrases: |
| 298 |
|
| 299 |
EACH Monday |
| 300 |
EVERY Monday |
| 301 |
EVERY month |
| 302 |
|
| 303 |
The following words may be used: |
| 304 |
|
| 305 |
$words{each} |
| 306 |
|
| 307 |
${e}item B<Next/Previous/Last occurrence> |
| 308 |
|
| 309 |
There are a list of words that may be used to specify the next, |
| 310 |
previous, or last occurrence of something. These words could be used |
| 311 |
in the following phrases: |
| 312 |
|
| 313 |
NEXT week |
| 314 |
|
| 315 |
LAST Tuesday |
| 316 |
PREVIOUS Tuesday |
| 317 |
|
| 318 |
LAST day of the month |
| 319 |
|
| 320 |
The following words may be used: |
| 321 |
|
| 322 |
Next occurrence: |
| 323 |
|
| 324 |
$words{nextprev}[0] |
| 325 |
|
| 326 |
Previous occurrence: |
| 327 |
|
| 328 |
$words{nextprev}[1] |
| 329 |
|
| 330 |
Last occurrence: |
| 331 |
|
| 332 |
$words{last} |
| 333 |
|
| 334 |
${e}item B<Delta words for going forward/backward in time> |
| 335 |
|
| 336 |
When parsing deltas, there are words that may be used to specify |
| 337 |
the the delta will refer to a time in the future or to a time in |
| 338 |
the past (relative to some date). In English, for example, you |
| 339 |
might say: |
| 340 |
|
| 341 |
IN 5 days |
| 342 |
5 days AGO |
| 343 |
|
| 344 |
The following words may be used to specify deltas that refer to |
| 345 |
dates in the past or future respectively: |
| 346 |
|
| 347 |
$words{when}[0] |
| 348 |
$words{when}[1] |
| 349 |
|
| 350 |
${e}item B<Business mode> |
| 351 |
|
| 352 |
This contains two lists of words which can be used to specify a standard |
| 353 |
(i.e. non-business) delta or a business delta. |
| 354 |
|
| 355 |
Previously, it was used to tell whether the delta was approximate or exact, |
| 356 |
but now this list is not used except to force the delta to be standard. |
| 357 |
|
| 358 |
The following words may be used: |
| 359 |
|
| 360 |
$words{mode}[0] |
| 361 |
|
| 362 |
The following words may be used to specify a business delta: |
| 363 |
|
| 364 |
$words{mode}[1] |
| 365 |
|
| 366 |
${e}item B<Numbers> |
| 367 |
|
| 368 |
Numbers may be spelled out in a variety of ways. The following sets correspond |
| 369 |
to the numbers from 1 to 53: |
| 370 |
|
| 371 |
$words{nth}[0] |
| 372 |
$words{nth}[1] |
| 373 |
$words{nth}[2] |
| 374 |
$words{nth}[3] |
| 375 |
$words{nth}[4] |
| 376 |
$words{nth}[5] |
| 377 |
$words{nth}[6] |
| 378 |
$words{nth}[7] |
| 379 |
$words{nth}[8] |
| 380 |
$words{nth}[9] |
| 381 |
|
| 382 |
$words{nth}[10] |
| 383 |
$words{nth}[11] |
| 384 |
$words{nth}[12] |
| 385 |
$words{nth}[13] |
| 386 |
$words{nth}[14] |
| 387 |
$words{nth}[15] |
| 388 |
$words{nth}[16] |
| 389 |
$words{nth}[17] |
| 390 |
$words{nth}[18] |
| 391 |
$words{nth}[19] |
| 392 |
|
| 393 |
$words{nth}[20] |
| 394 |
$words{nth}[21] |
| 395 |
$words{nth}[22] |
| 396 |
$words{nth}[23] |
| 397 |
$words{nth}[24] |
| 398 |
$words{nth}[25] |
| 399 |
$words{nth}[26] |
| 400 |
$words{nth}[27] |
| 401 |
$words{nth}[28] |
| 402 |
$words{nth}[29] |
| 403 |
|
| 404 |
$words{nth}[30] |
| 405 |
$words{nth}[31] |
| 406 |
$words{nth}[32] |
| 407 |
$words{nth}[33] |
| 408 |
$words{nth}[34] |
| 409 |
$words{nth}[35] |
| 410 |
$words{nth}[36] |
| 411 |
$words{nth}[37] |
| 412 |
$words{nth}[38] |
| 413 |
$words{nth}[39] |
| 414 |
|
| 415 |
$words{nth}[40] |
| 416 |
$words{nth}[41] |
| 417 |
$words{nth}[42] |
| 418 |
$words{nth}[43] |
| 419 |
$words{nth}[44] |
| 420 |
$words{nth}[45] |
| 421 |
$words{nth}[46] |
| 422 |
$words{nth}[47] |
| 423 |
$words{nth}[48] |
| 424 |
$words{nth}[49] |
| 425 |
|
| 426 |
$words{nth}[50] |
| 427 |
$words{nth}[51] |
| 428 |
$words{nth}[52] |
| 429 |
|
| 430 |
${e}item B<Ignored words> |
| 431 |
|
| 432 |
In writing out dates in common forms, there are a number of words |
| 433 |
that are typically not important. |
| 434 |
|
| 435 |
There is frequently a word that appears in a phrase to designate |
| 436 |
that a time is going to be specified next. In English, you would |
| 437 |
use the word AT in the example: |
| 438 |
|
| 439 |
December 3 at 12:00 |
| 440 |
|
| 441 |
The following words may be used: |
| 442 |
|
| 443 |
$words{at} |
| 444 |
|
| 445 |
Another word is used to designate one member of a set. In English, |
| 446 |
you would use the words IN or OF: |
| 447 |
|
| 448 |
1st day OF December |
| 449 |
1st day IN December |
| 450 |
|
| 451 |
The following words may be used: |
| 452 |
|
| 453 |
$words{of} |
| 454 |
|
| 455 |
Another word is use to specify that something is on a certain date. In |
| 456 |
English, you would use ON: |
| 457 |
|
| 458 |
ON July 5th |
| 459 |
|
| 460 |
The following words may be used: |
| 461 |
|
| 462 |
$words{on} |
| 463 |
|
| 464 |
${e}item B<Words that set the date, time, or both> |
| 465 |
|
| 466 |
There are some words that can be used to specify a date, a |
| 467 |
time, or both relative to now. |
| 468 |
|
| 469 |
Words that set the date are similar to the English words 'yesterday' |
| 470 |
or 'tomorrow'. These are specified as a delta which is added to the |
| 471 |
current time to get a date. The time is NOT set however, so the delta |
| 472 |
is only partially used (it should only include year, month, week, and |
| 473 |
day fields). |
| 474 |
|
| 475 |
The following words may be used: |
| 476 |
|
| 477 |
$words{offset_date} |
| 478 |
|
| 479 |
Words that set only the time of day are similar to the English words |
| 480 |
'noon' or 'midnight'. |
| 481 |
|
| 482 |
The following words may be used: |
| 483 |
|
| 484 |
$words{times} |
| 485 |
|
| 486 |
Words that set the entire time and date (relative to the current |
| 487 |
time and date) are also available. |
| 488 |
|
| 489 |
In English, the word 'now' is one of these. |
| 490 |
|
| 491 |
The following words may be used: |
| 492 |
|
| 493 |
$words{offset_time} |
| 494 |
|
| 495 |
${e}item B<Hour/Minute/Second separators> |
| 496 |
|
| 497 |
When specifying the time of day, the most common separator is a colon (:) |
| 498 |
which can be used for both separators. |
| 499 |
|
| 500 |
Some languages use different pairs. For example, French allows you to |
| 501 |
specify the time as 13h30:20, so it would use the following pairs: |
| 502 |
|
| 503 |
: : |
| 504 |
h : |
| 505 |
|
| 506 |
The first column is the hour-minute separator and the second column is |
| 507 |
the minute-second separator. Both are perl regular expressions. When |
| 508 |
creating a new translation, be aware that regular expressions with utf-8 |
| 509 |
characters may be tricky. For example, don't include the expression '[x]' |
| 510 |
where 'x' is a utf-8 character. |
| 511 |
|
| 512 |
A pair of colons is ALWAYS allowed for all languages. If a language allows |
| 513 |
additional pairs, they are listed here: |
| 514 |
|
| 515 |
$words{seps} |
| 516 |
|
| 517 |
${e}item B<Fractional second separator> |
| 518 |
|
| 519 |
When specifying fractional seconds, the most common way is to use a |
| 520 |
decimal point (.). Some languages may specify a different separator |
| 521 |
that might be used. If this is done, it is a regular expression. |
| 522 |
|
| 523 |
The decimal point is ALWAYS allowed for all languages. If a language allows |
| 524 |
another separator, it is listed here: |
| 525 |
|
| 526 |
$words{sepfr} |
| 527 |
|
| 528 |
${e}back |
| 529 |
|
| 530 |
${e}head1 KNOWN BUGS |
| 531 |
|
| 532 |
None known. |
| 533 |
|
| 534 |
${e}head1 BUGS AND QUESTIONS |
| 535 |
|
| 536 |
Please refer to the L<Date::Manip::Problems> documentation for |
| 537 |
information on submitting bug reports or questions to the author. |
| 538 |
|
| 539 |
${e}head1 SEE ALSO |
| 540 |
|
| 541 |
L<Date::Manip> - main module documentation |
| 542 |
|
| 543 |
${e}head1 LICENSE |
| 544 |
|
| 545 |
This script is free software; you can redistribute it and/or |
| 546 |
modify it under the same terms as Perl itself. |
| 547 |
|
| 548 |
${e}head1 AUTHOR |
| 549 |
|
| 550 |
Sullivan Beck (sbeck\@cpan.org) |
| 551 |
|
| 552 |
${e}cut |
| 553 |
EOF |
| 554 |
|
| 555 |
$out->close(); |
| 556 |
} |
| 557 |
use strict 'refs'; |
| 558 |
|
| 559 |
# Local Variables: |
| 560 |
# mode: cperl |
| 561 |
# indent-tabs-mode: nil |
| 562 |
# cperl-indent-level: 3 |
| 563 |
# cperl-continued-statement-offset: 2 |
| 564 |
# cperl-continued-brace-offset: 0 |
| 565 |
# cperl-brace-offset: 0 |
| 566 |
# cperl-brace-imaginary-offset: 0 |
| 567 |
# cperl-label-offset: 0 |
| 568 |
# End: |