| 1 |
==================================== |
|---|
| 2 |
Package "Date::Calc" Version 5.3 |
|---|
| 3 |
==================================== |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
Copyright (c) 1995 - 2002 by Steffen Beyer. |
|---|
| 7 |
All rights reserved. |
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
Example applications: |
|---|
| 11 |
--------------------- |
|---|
| 12 |
|
|---|
| 13 |
You will find some example programs (several in Perl, one in C) |
|---|
| 14 |
in the "examples" subdirectory of this distribution: |
|---|
| 15 |
|
|---|
| 16 |
examples/age_in_days_eu.pl |
|---|
| 17 |
examples/age_in_days_us.pl |
|---|
| 18 |
examples/anniversaries.pl |
|---|
| 19 |
examples/cal.c |
|---|
| 20 |
examples/calendar.cgi |
|---|
| 21 |
examples/delta.pl |
|---|
| 22 |
examples/holidays.pl |
|---|
| 23 |
examples/income.pl |
|---|
| 24 |
examples/linearcal.pl |
|---|
| 25 |
examples/nth_weekday.pl |
|---|
| 26 |
examples/time.pl |
|---|
| 27 |
examples/vacation.pl |
|---|
| 28 |
examples/weiberfastnacht.pl |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
age_in_days_eu.pl, age_in_days_us.pl: |
|---|
| 32 |
------------------------------------- |
|---|
| 33 |
|
|---|
| 34 |
"age_in_days_eu.pl" and "age_in_days_us.pl" are a demonstration of the |
|---|
| 35 |
multi-language capabilities of this package, as well as of its scanning |
|---|
| 36 |
capabilities for dates. |
|---|
| 37 |
|
|---|
| 38 |
First build and install this package (for instructions, see the file |
|---|
| 39 |
"INSTALL.txt" in this distribution), then change directory to the |
|---|
| 40 |
"examples" subdirectory, and finally start these two demo programs |
|---|
| 41 |
with |
|---|
| 42 |
% perl age_in_days_eu.pl |
|---|
| 43 |
and |
|---|
| 44 |
% perl age_in_days_us.pl |
|---|
| 45 |
respectively. |
|---|
| 46 |
|
|---|
| 47 |
They first ask you to choose a language; any uniquely identifying |
|---|
| 48 |
abbreviation for one of the first six languages supported by this |
|---|
| 49 |
package (English, French, German, Spanish, Portuguese, Dutch) will |
|---|
| 50 |
suffice, like "en" for "English", "es" for "Español" (Spanish), |
|---|
| 51 |
"f" for "Français" (French), and so on. |
|---|
| 52 |
|
|---|
| 53 |
These applications then ask you to enter the date of your birthday. |
|---|
| 54 |
|
|---|
| 55 |
The two applications only differ in the expected format for dates: |
|---|
| 56 |
In "age_in_days_eu.pl", the order day-month-year is assumed, whereas |
|---|
| 57 |
"age_in_days_us.pl" assumes the order month-day-year. |
|---|
| 58 |
|
|---|
| 59 |
For the month you can (at your option) either enter the corresponding |
|---|
| 60 |
number, or any uniquely identifying abbreviation of the month's name |
|---|
| 61 |
(or the name of the month in full length) IN THE CHOSEN LANGUAGE. |
|---|
| 62 |
|
|---|
| 63 |
Moreover, virtually any format for dates is supported: |
|---|
| 64 |
|
|---|
| 65 |
Examples include "03/01/64", "3.1.1964", "January 3rd, 1964", "030164", |
|---|
| 66 |
and so on. |
|---|
| 67 |
|
|---|
| 68 |
Experiment! |
|---|
| 69 |
|
|---|
| 70 |
Note that the scanning itself is actually performed by two powerful |
|---|
| 71 |
routines written in C, and not using the regular expressions from Perl |
|---|
| 72 |
(which would make this task rather trivial in Perl, but which wouldn't |
|---|
| 73 |
be easily accessible to C programmers). |
|---|
| 74 |
|
|---|
| 75 |
After confirming your entry, the program will print out your age in days. |
|---|
| 76 |
|
|---|
| 77 |
If the system call "time()" (and hence, "localtime()") is not available |
|---|
| 78 |
on your system, the program will also ask you to enter today's date. |
|---|
| 79 |
|
|---|
| 80 |
Otherwise the program will automatically use the system-supplied current |
|---|
| 81 |
date. |
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
anniversaries.pl: |
|---|
| 85 |
----------------- |
|---|
| 86 |
|
|---|
| 87 |
This script demonstrates how one can use the Date::Calendar module to |
|---|
| 88 |
get a list of anniversaries for the next couple of weeks. |
|---|
| 89 |
|
|---|
| 90 |
If you run this program from the login script of your shell, you will |
|---|
| 91 |
always get this list when you log in, and you will never ever forget |
|---|
| 92 |
a birthday or anniversary again! (At least you won't have an excuse |
|---|
| 93 |
anymore. :-) ) |
|---|
| 94 |
|
|---|
| 95 |
Your dear loving wife or husband will appreciate it! ;-) |
|---|
| 96 |
|
|---|
| 97 |
Example output (on October 3rd, 2001): |
|---|
| 98 |
|
|---|
| 99 |
+13 days : Tue 16-Oct-2001 (31) Cousin Paul |
|---|
| 100 |
+18 days : Sun 21-Oct-2001 (28) Sister Catherine |
|---|
| 101 |
+88 days : Sun 30-Dec-2001 (30) Spouse |
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
cal.c: |
|---|
| 105 |
------ |
|---|
| 106 |
|
|---|
| 107 |
This little program is a substitute for the UNIX "cal" command. |
|---|
| 108 |
|
|---|
| 109 |
In contrast to the UNIX "cal" command, however, this program allows you |
|---|
| 110 |
to choose a language which will be used for generating the calendar for |
|---|
| 111 |
the chosen month and year. |
|---|
| 112 |
|
|---|
| 113 |
(Also in contrast to the UNIX "cal" command, this program will NOT |
|---|
| 114 |
generate a tiled overview of ALL the months for a given year, however.) |
|---|
| 115 |
|
|---|
| 116 |
Moreover, you can (at your option) either enter the number of the desired |
|---|
| 117 |
language, or any uniquely identifying abbreviation of its name (or the name |
|---|
| 118 |
in full length). |
|---|
| 119 |
|
|---|
| 120 |
For the month you can also (at your option) either enter the corresponding |
|---|
| 121 |
number, or any uniquely identifying abbreviation of the month's name (or |
|---|
| 122 |
the name of the month in full length) *IN THE CHOSEN LANGUAGE*. |
|---|
| 123 |
|
|---|
| 124 |
In order to compile this little program, first copy the file "cal.c" from |
|---|
| 125 |
the "examples" subdirectory to the main directory of this distribution. |
|---|
| 126 |
|
|---|
| 127 |
BEWARE that you should REMOVE this file ("cal.c") from the MAIN directory |
|---|
| 128 |
of this distribution BEFORE building this package (i.e., before issuing |
|---|
| 129 |
the command "perl Makefile.PL"), because you may get compiler or runtime |
|---|
| 130 |
errors (like "duplicate main() function") otherwise. At the very least, |
|---|
| 131 |
this will inflate your shared library ("Calc.so") unnecessarily if you |
|---|
| 132 |
don't. |
|---|
| 133 |
|
|---|
| 134 |
In order to successfully compile the "cal.c" program, you do NOT need |
|---|
| 135 |
to build the Date::Calc package first, however. |
|---|
| 136 |
|
|---|
| 137 |
Then change directory to the main directory of this distribution, |
|---|
| 138 |
if you haven't done so already. |
|---|
| 139 |
|
|---|
| 140 |
Finally, if you have Perl available on your system (no matter whether |
|---|
| 141 |
UNIX or Win32), you can compile this program with the following command: |
|---|
| 142 |
|
|---|
| 143 |
% perl tools/compile.pl cal.c DateCalc.c |
|---|
| 144 |
or |
|---|
| 145 |
% perl tools\compile.pl cal.c DateCalc.c |
|---|
| 146 |
|
|---|
| 147 |
Otherwise, if you have the GNU C compiler ("gcc") available on your system, |
|---|
| 148 |
you can also do so (UNIX only) using the command |
|---|
| 149 |
|
|---|
| 150 |
% ./tools/compile.sh cal.c DateCalc.c |
|---|
| 151 |
|
|---|
| 152 |
On a MSDOS/Windows system, if your ANSI C compiler can be called with "cl", |
|---|
| 153 |
you can also compile the program using the command |
|---|
| 154 |
|
|---|
| 155 |
% tools\compile cal DateCalc.c |
|---|
| 156 |
|
|---|
| 157 |
(Note the missing ".c" at the end of the filename "cal" in this case!) |
|---|
| 158 |
|
|---|
| 159 |
Otherwise, compile the program with your favourite ANSI C compiler in a |
|---|
| 160 |
similar fashion. |
|---|
| 161 |
|
|---|
| 162 |
In case you have already built the Date::Calc package, you can simply |
|---|
| 163 |
say |
|---|
| 164 |
% perl tools/compile.pl cal.c DateCalc.o |
|---|
| 165 |
|
|---|
| 166 |
(note the "o" at the end of the line instead of a "c") or |
|---|
| 167 |
|
|---|
| 168 |
% perl tools\compile.pl cal.c DateCalc.obj |
|---|
| 169 |
|
|---|
| 170 |
under Windows. |
|---|
| 171 |
|
|---|
| 172 |
Now start the program with the command "./cal" (UNIX) or simply "cal" |
|---|
| 173 |
(MSDOS/Windows). |
|---|
| 174 |
|
|---|
| 175 |
(Note that this program is not confined to Win32 systems, it also compiles |
|---|
| 176 |
and runs perfectly well on pure MS-DOS or other Windows systems!) |
|---|
| 177 |
|
|---|
| 178 |
The first parameter is the desired language (currently 1..11 or "English", |
|---|
| 179 |
"Français", "Deutsch", "Español", "Português", "Nederlands", "Italiano", |
|---|
| 180 |
"Norsk", "Svenska", "Dansk" and "suomi"), the second the month and the |
|---|
| 181 |
third the year. |
|---|
| 182 |
|
|---|
| 183 |
Example: |
|---|
| 184 |
% cal en apr 1998 |
|---|
| 185 |
|
|---|
| 186 |
This will print: |
|---|
| 187 |
|
|---|
| 188 |
April 1998 |
|---|
| 189 |
Mon Tue Wed Thu Fri Sat Sun |
|---|
| 190 |
1 2 3 4 5 |
|---|
| 191 |
6 7 8 9 10 11 12 |
|---|
| 192 |
13 14 15 16 17 18 19 |
|---|
| 193 |
20 21 22 23 24 25 26 |
|---|
| 194 |
27 28 29 30 |
|---|
| 195 |
|
|---|
| 196 |
If you start the "cal" program without parameters, it will print a usage |
|---|
| 197 |
and exit. |
|---|
| 198 |
|
|---|
| 199 |
Experiment! |
|---|
| 200 |
|
|---|
| 201 |
If you like this program, you might want to copy it to some directory in |
|---|
| 202 |
your search path, like "/usr/local/bin" (UNIX) or "C:\DOS" or "C:\WinNT" |
|---|
| 203 |
(MSDOS/Windows). |
|---|
| 204 |
|
|---|
| 205 |
If you are running this program on a PC (e.g. MS-DOS, Windows DOS box, |
|---|
| 206 |
GNU/Linux or FreeBSD console), you might want to pipe its output through |
|---|
| 207 |
the "iso2pc" filter from the "tools" subdirectory (see the file "TOOLS.txt" |
|---|
| 208 |
in this distribution for instructions on how to compile and install this |
|---|
| 209 |
filter), in order to convert the special international characters from |
|---|
| 210 |
the ISO-Latin-1 character set (used throughout this package) to one of |
|---|
| 211 |
the (two) character sets commonly used on PC's, as follows: |
|---|
| 212 |
|
|---|
| 213 |
% cal Portug Mar 1998 | iso2pc [-dos] |
|---|
| 214 |
|
|---|
| 215 |
(for older versions of MS-DOS and the PC-UNIX console) or |
|---|
| 216 |
|
|---|
| 217 |
% cal Portug Mar 1998 | iso2pc -win |
|---|
| 218 |
|
|---|
| 219 |
(for newer versions of MS-DOS and the Win32 DOS box). |
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
calendar.cgi: |
|---|
| 223 |
------------- |
|---|
| 224 |
|
|---|
| 225 |
This CGI script demonstrates the capabilities of the new "Calendar::*" |
|---|
| 226 |
modules. |
|---|
| 227 |
|
|---|
| 228 |
See http://www.engelschall.com/u/sb/calendar/ for a "live" example of |
|---|
| 229 |
this script and play around with it at leisure! |
|---|
| 230 |
|
|---|
| 231 |
The script allows you to select a language, a calendar profile, a start |
|---|
| 232 |
"Year and Month" or start "Week and Year" and displays a calendar for the |
|---|
| 233 |
chosen month, or for 4 consecutive weeks starting with the chosen week, |
|---|
| 234 |
for the chosen location (calendar profile) and in the chosen language. |
|---|
| 235 |
|
|---|
| 236 |
(The language setting only affects the names of months and days of week, |
|---|
| 237 |
though! The language of the names of the holidays and commemorative days |
|---|
| 238 |
is determined by the calendar profiles themselves.) |
|---|
| 239 |
|
|---|
| 240 |
Alternately, you can choose to display a whole year, either only the |
|---|
| 241 |
true holidays (i.e., the days on which you get a day off, that is, all |
|---|
| 242 |
official holidays which do not fall on a Saturday or Sunday), or all |
|---|
| 243 |
the days for which the corresponding profile has names stored in it |
|---|
| 244 |
(official holidays as well as commemorative days). |
|---|
| 245 |
|
|---|
| 246 |
Choosing one of these two options (radio buttons) overrides the "Year |
|---|
| 247 |
and Month" or "Week and Year" mode of operation, but nevertheless takes |
|---|
| 248 |
its year argument from the selected entry field (and simply drops the |
|---|
| 249 |
"Month" or "Week" value). |
|---|
| 250 |
|
|---|
| 251 |
(Since the two year numbers in either mode might not be the same, be |
|---|
| 252 |
careful which mode you choose and which input field you type into!) |
|---|
| 253 |
|
|---|
| 254 |
Saturdays, Sundays and official holidays will be marked in red, "half" |
|---|
| 255 |
holidays will be marked in purple. Workdays are printed in black. |
|---|
| 256 |
|
|---|
| 257 |
All the names associated with each day (the names of official holidays |
|---|
| 258 |
as well as purely commemorative days) are displayed to the right of |
|---|
| 259 |
each day. |
|---|
| 260 |
|
|---|
| 261 |
Please report any errors you find in the calendar profiles (or in this |
|---|
| 262 |
script) back to me! |
|---|
| 263 |
|
|---|
| 264 |
There is a "mailto:" hyperlink at the bottom of the generated page for |
|---|
| 265 |
this purpose. |
|---|
| 266 |
|
|---|
| 267 |
Thank you very much in advance! |
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
delta.pl: |
|---|
| 271 |
--------- |
|---|
| 272 |
|
|---|
| 273 |
This is a little program which contains a routine to determine the |
|---|
| 274 |
number of business days between two dates. It is not of much practical |
|---|
| 275 |
value, because it doesn't take legal holidays into account (use the |
|---|
| 276 |
method "delta_weekdays()" in the module Date::Calendar[::Year] if you |
|---|
| 277 |
want to do that, or see the examples "income.pl" and "vacation.pl" |
|---|
| 278 |
below). |
|---|
| 279 |
|
|---|
| 280 |
Moreover, it assumes that counting includes the earlier of the two |
|---|
| 281 |
dates, but not the later one. I.e., if you determine the number of |
|---|
| 282 |
business days between, for example, two consecutive days, like for |
|---|
| 283 |
instance a Friday and a Saturday, the routine will return a difference |
|---|
| 284 |
of one business day as the result. If you take a Sunday and Monday, on |
|---|
| 285 |
the other hand, however, it will give you a difference of zero business |
|---|
| 286 |
days. |
|---|
| 287 |
|
|---|
| 288 |
The program expects six parameters on the command line, i.e., two dates |
|---|
| 289 |
in the order year, month, day, in chronological order (the result will |
|---|
| 290 |
be negative if you swap the two dates, but the routine won't go backwards |
|---|
| 291 |
in time, i.e., it still counts the earlier date if it is a business day, |
|---|
| 292 |
but not the later one). If the number of command line parameters is not |
|---|
| 293 |
six, the program prints a usage and exits. |
|---|
| 294 |
|
|---|
| 295 |
Here's an example of how it can be used: |
|---|
| 296 |
|
|---|
| 297 |
% perl delta.pl 1999 12 24 2000 1 8 |
|---|
| 298 |
|
|---|
| 299 |
Fri 24-Dec-1999 |
|---|
| 300 |
Sat 8-Jan-2000 |
|---|
| 301 |
|
|---|
| 302 |
December 1999 |
|---|
| 303 |
Mon Tue Wed Thu Fri Sat Sun |
|---|
| 304 |
1 2 3 4 5 |
|---|
| 305 |
6 7 8 9 10 11 12 |
|---|
| 306 |
13 14 15 16 17 18 19 |
|---|
| 307 |
20 21 22 23 24 25 26 |
|---|
| 308 |
27 28 29 30 31 |
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
January 2000 |
|---|
| 312 |
Mon Tue Wed Thu Fri Sat Sun |
|---|
| 313 |
1 2 |
|---|
| 314 |
3 4 5 6 7 8 9 |
|---|
| 315 |
10 11 12 13 14 15 16 |
|---|
| 316 |
17 18 19 20 21 22 23 |
|---|
| 317 |
24 25 26 27 28 29 30 |
|---|
| 318 |
31 |
|---|
| 319 |
|
|---|
| 320 |
Difference: 11 Business Days. |
|---|
| 321 |
|
|---|
| 322 |
(The program prints the calendars of the respective months so that you |
|---|
| 323 |
can verify its results.) |
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 |
holidays.pl: |
|---|
| 327 |
------------ |
|---|
| 328 |
|
|---|
| 329 |
This utility generates a list of all holidays and commemorative |
|---|
| 330 |
days for a given year and location. |
|---|
| 331 |
|
|---|
| 332 |
It also shows how to temporarily change the language and date |
|---|
| 333 |
string format, produce some output, and restore the old values. |
|---|
| 334 |
|
|---|
| 335 |
Given a year number, the name of a language and the name of one |
|---|
| 336 |
of the predefined calendar profiles, this subroutine prints a list |
|---|
| 337 |
of all holidays in the given year, such as in the following example: |
|---|
| 338 |
|
|---|
| 339 |
:> perl holidays.pl 2001 de sdm-MUC |
|---|
| 340 |
|
|---|
| 341 |
Mon 01-Jan-2001 + Neujahr |
|---|
| 342 |
Sam 06-Jan-2001 + Dreikönigstag |
|---|
| 343 |
Don 22-Feb-2001 - Fettdonnerstag, Weiberfastnacht |
|---|
| 344 |
Mon 26-Feb-2001 - Rosenmontag |
|---|
| 345 |
Die 27-Feb-2001 - Karnevalsdienstag |
|---|
| 346 |
Mit 28-Feb-2001 - Aschermittwoch |
|---|
| 347 |
Son 08-Apr-2001 + Palmsonntag |
|---|
| 348 |
Don 12-Apr-2001 - Gründonnerstag |
|---|
| 349 |
Fre 13-Apr-2001 + Karfreitag |
|---|
| 350 |
Son 15-Apr-2001 + Ostersonntag |
|---|
| 351 |
Mon 16-Apr-2001 + Ostermontag |
|---|
| 352 |
Die 01-Mai-2001 + Tag der Arbeit |
|---|
| 353 |
Don 24-Mai-2001 + Christi Himmelfahrt |
|---|
| 354 |
Son 03-Jun-2001 + Pfingstsonntag |
|---|
| 355 |
Mon 04-Jun-2001 + Pfingstmontag |
|---|
| 356 |
Don 14-Jun-2001 + Fronleichnam |
|---|
| 357 |
Mit 15-Aug-2001 + Mariä Himmelfahrt |
|---|
| 358 |
Mit 03-Okt-2001 + Tag der deutschen Einheit |
|---|
| 359 |
Mit 31-Okt-2001 - Reformationstag |
|---|
| 360 |
Don 01-Nov-2001 + Allerheiligen |
|---|
| 361 |
Mit 21-Nov-2001 - Buß- und Bettag |
|---|
| 362 |
Son 02-Dez-2001 + 1. Advent |
|---|
| 363 |
Son 09-Dez-2001 + 2. Advent |
|---|
| 364 |
Son 16-Dez-2001 + 3. Advent |
|---|
| 365 |
Son 23-Dez-2001 + 4. Advent |
|---|
| 366 |
Mon 24-Dez-2001 # Heiligabend |
|---|
| 367 |
Die 25-Dez-2001 + 1. Weihnachtsfeiertag |
|---|
| 368 |
Mit 26-Dez-2001 + 2. Weihnachtsfeiertag |
|---|
| 369 |
Mon 31-Dez-2001 # Sylvester |
|---|
| 370 |
|
|---|
| 371 |
Holidays and weekends are marked with "+", "half" holidays are |
|---|
| 372 |
marked with "#", and commemorative days (days which aren't legal |
|---|
| 373 |
holidays but which have a special name) or normal weekdays are |
|---|
| 374 |
marked with "-". |
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
income.pl: |
|---|
| 378 |
---------- |
|---|
| 379 |
|
|---|
| 380 |
This little program demonstrates what you can do using the Date::Calendar, |
|---|
| 381 |
Date::Calendar::Year and Date::Calendar::Profiles modules, which allow you |
|---|
| 382 |
to perform calculations which take (legal and any other you want) holidays |
|---|
| 383 |
into account. |
|---|
| 384 |
|
|---|
| 385 |
It expects four parameters on the command line: Your year of birth, the |
|---|
| 386 |
number of days of (paid) vacation your employer concedes you (per year), |
|---|
| 387 |
the number of hours per week that you work, and your brut annual income. |
|---|
| 388 |
|
|---|
| 389 |
If called without or with a wrong number of parameters, the program prints |
|---|
| 390 |
a usage and stops. |
|---|
| 391 |
|
|---|
| 392 |
Otherwise, it prints a summary of your input, a list of years, followed |
|---|
| 393 |
by the number of workdays in that year, some statistics, and your average |
|---|
| 394 |
net wage per hour (assuming 50% taxes on income and an age of 65 for |
|---|
| 395 |
retirement). |
|---|
| 396 |
|
|---|
| 397 |
Note that you may have to adjust the holidays profile used in this script |
|---|
| 398 |
before you can get any meaningful results for your location. The currently |
|---|
| 399 |
used profile is for the federal state of Nordrhein-Westfalen in Germany. |
|---|
| 400 |
See the manual page (and code) of the Date::Calendar::Profiles module |
|---|
| 401 |
for more information. |
|---|
| 402 |
|
|---|
| 403 |
Sample run: |
|---|
| 404 |
|
|---|
| 405 |
:> perl income.pl 1964 30 40 100000 |
|---|
| 406 |
|
|---|
| 407 |
Year of birth = 1964 |
|---|
| 408 |
Current year = 2001 |
|---|
| 409 |
Year of retirement = 2029 |
|---|
| 410 |
Vacation days/year = 30 |
|---|
| 411 |
Hours per week = 40 |
|---|
| 412 |
Brut annual income = 100000 |
|---|
| 413 |
|
|---|
| 414 |
2001 : 220 |
|---|
| 415 |
2002 : 220 |
|---|
| 416 |
2003 : 221 |
|---|
| 417 |
2004 : 225 |
|---|
| 418 |
2005 : 222 |
|---|
| 419 |
2006 : 220 |
|---|
| 420 |
2007 : 220 |
|---|
| 421 |
2008 : 223 |
|---|
| 422 |
2009 : 223 |
|---|
| 423 |
2010 : 224 |
|---|
| 424 |
2011 : 222 |
|---|
| 425 |
2012 : 221 |
|---|
| 426 |
2013 : 220 |
|---|
| 427 |
2014 : 221 |
|---|
| 428 |
2015 : 223 |
|---|
| 429 |
2016 : 222 |
|---|
| 430 |
2017 : 220 |
|---|
| 431 |
2018 : 220 |
|---|
| 432 |
2019 : 220 |
|---|
| 433 |
2020 : 224 |
|---|
| 434 |
2021 : 224 |
|---|
| 435 |
2022 : 222 |
|---|
| 436 |
2023 : 220 |
|---|
| 437 |
2024 : 221 |
|---|
| 438 |
2025 : 221 |
|---|
| 439 |
2026 : 223 |
|---|
| 440 |
2027 : 224 |
|---|
| 441 |
2028 : 220 |
|---|
| 442 |
2029 : 220 |
|---|
| 443 |
|
|---|
| 444 |
Total workdays = 6426 |
|---|
| 445 |
Average workdays per year = 221.586206896552 |
|---|
| 446 |
|
|---|
| 447 |
Total days = 10592 |
|---|
| 448 |
Average year length in days = 365.241379310345 |
|---|
| 449 |
|
|---|
| 450 |
Quotient = 0.606684290030212 |
|---|
| 451 |
|
|---|
| 452 |
Net hourly wages (assuming 50% taxes on income) = 28.2057267351385 |
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
linearcal.pl: |
|---|
| 456 |
------------- |
|---|
| 457 |
|
|---|
| 458 |
This program illustrates how to use the various new methods |
|---|
| 459 |
available through the new object-oriented date and calendar modules |
|---|
| 460 |
(Date::Calc::Object, Date::Calendar, Date::Calendar::Profiles). |
|---|
| 461 |
|
|---|
| 462 |
It also shows how to temporarily change the language and date |
|---|
| 463 |
string format, produce some output, and restore the old values. |
|---|
| 464 |
|
|---|
| 465 |
Given two dates (start and stop date), the name of a language |
|---|
| 466 |
and the name of one of the predefined calendar profiles, this |
|---|
| 467 |
little subroutine prints a linear calendar, such as in the |
|---|
| 468 |
following two examples: |
|---|
| 469 |
|
|---|
| 470 |
:> perl linearcal.pl 1999 12 18 2000 1 9 de DE-BY |
|---|
| 471 |
|
|---|
| 472 |
Sam 18-Dez-1999 + |
|---|
| 473 |
Son 19-Dez-1999 + 4. Advent |
|---|
| 474 |
Mon 20-Dez-1999 - |
|---|
| 475 |
Die 21-Dez-1999 - |
|---|
| 476 |
Mit 22-Dez-1999 - |
|---|
| 477 |
Don 23-Dez-1999 - |
|---|
| 478 |
Fre 24-Dez-1999 - Heiligabend |
|---|
| 479 |
Sam 25-Dez-1999 + 1. Weihnachtsfeiertag |
|---|
| 480 |
Son 26-Dez-1999 + 2. Weihnachtsfeiertag |
|---|
| 481 |
Mon 27-Dez-1999 - |
|---|
| 482 |
Die 28-Dez-1999 - |
|---|
| 483 |
Mit 29-Dez-1999 - |
|---|
| 484 |
Don 30-Dez-1999 - |
|---|
| 485 |
Fre 31-Dez-1999 - Sylvester |
|---|
| 486 |
Sam 01-Jan-2000 + Neujahr |
|---|
| 487 |
Son 02-Jan-2000 + |
|---|
| 488 |
Mon 03-Jan-2000 - |
|---|
| 489 |
Die 04-Jan-2000 - |
|---|
| 490 |
Mit 05-Jan-2000 - |
|---|
| 491 |
Don 06-Jan-2000 + Dreikönigstag |
|---|
| 492 |
Fre 07-Jan-2000 - |
|---|
| 493 |
Sam 08-Jan-2000 + |
|---|
| 494 |
Son 09-Jan-2000 + |
|---|
| 495 |
|
|---|
| 496 |
:> perl linearcal.pl 1999 12 18 2000 1 9 en GB |
|---|
| 497 |
|
|---|
| 498 |
Sat 18-Dec-1999 + |
|---|
| 499 |
Sun 19-Dec-1999 + |
|---|
| 500 |
Mon 20-Dec-1999 - |
|---|
| 501 |
Tue 21-Dec-1999 - |
|---|
| 502 |
Wed 22-Dec-1999 - |
|---|
| 503 |
Thu 23-Dec-1999 - |
|---|
| 504 |
Fri 24-Dec-1999 - |
|---|
| 505 |
Sat 25-Dec-1999 + |
|---|
| 506 |
Sun 26-Dec-1999 + |
|---|
| 507 |
Mon 27-Dec-1999 + Christmas Day |
|---|
| 508 |
Tue 28-Dec-1999 + Boxing Day |
|---|
| 509 |
Wed 29-Dec-1999 - |
|---|
| 510 |
Thu 30-Dec-1999 - |
|---|
| 511 |
Fri 31-Dec-1999 - |
|---|
| 512 |
Sat 01-Jan-2000 + |
|---|
| 513 |
Sun 02-Jan-2000 + |
|---|
| 514 |
Mon 03-Jan-2000 + New Year's Day |
|---|
| 515 |
Tue 04-Jan-2000 - |
|---|
| 516 |
Wed 05-Jan-2000 - |
|---|
| 517 |
Thu 06-Jan-2000 - |
|---|
| 518 |
Fri 07-Jan-2000 - |
|---|
| 519 |
Sat 08-Jan-2000 + |
|---|
| 520 |
Sun 09-Jan-2000 + |
|---|
| 521 |
|
|---|
| 522 |
Holidays and weekends are marked with "+", "half" holidays are |
|---|
| 523 |
marked with "#", and commemorative days (days which aren't legal |
|---|
| 524 |
holidays but which have a special name) or normal weekdays are |
|---|
| 525 |
marked with "-". |
|---|
| 526 |
|
|---|
| 527 |
|
|---|
| 528 |
nth_weekday.pl: |
|---|
| 529 |
--------------- |
|---|
| 530 |
|
|---|
| 531 |
This program is a demonstration of the function "Nth_Weekday_of_Month_Year()" |
|---|
| 532 |
and the scanning capabilities of this package (in particular the day of week |
|---|
| 533 |
and month, in this case). |
|---|
| 534 |
|
|---|
| 535 |
It calculates the date of the "n"th occurrence of the given day of week |
|---|
| 536 |
in the chosen month and year -- such as, for example, the 3rd Thursday |
|---|
| 537 |
of a given month and year. |
|---|
| 538 |
|
|---|
| 539 |
First build and install this package (for instructions, see the file |
|---|
| 540 |
"INSTALL.txt" in this distribution), then change directory to the |
|---|
| 541 |
"examples" subdirectory, and finally start this program with the |
|---|
| 542 |
following command (example): |
|---|
| 543 |
|
|---|
| 544 |
% perl nth_weekday.pl 3rd Thursday April 1998 |
|---|
| 545 |
|
|---|
| 546 |
This will print: |
|---|
| 547 |
|
|---|
| 548 |
The 3rd Thursday in April 1998 is Thursday, April 16th 1998. |
|---|
| 549 |
|
|---|
| 550 |
If you start this program without parameters, it will print a usage |
|---|
| 551 |
and exit. |
|---|
| 552 |
|
|---|
| 553 |
Note that you can enter the factor ("3rd" in the above example) either |
|---|
| 554 |
using plain numeric digits ("1", "2", "3", "4" and "5"), or in the usual |
|---|
| 555 |
abbreviated (English) form as "1st", "2nd", "3rd", "4th" and "5th". |
|---|
| 556 |
|
|---|
| 557 |
You can also enter the day of week either numerically ("1" through "7"), |
|---|
| 558 |
or as any uniquely identifying abbreviation of the name of the desired |
|---|
| 559 |
day of week (or its name in full length) in English. |
|---|
| 560 |
|
|---|
| 561 |
For the month you can similarly either enter the corresponding number |
|---|
| 562 |
("1" through "12"), or any uniquely identifying abbreviation of the |
|---|
| 563 |
month's name (or the name of the month in full length) in English. |
|---|
| 564 |
|
|---|
| 565 |
Experiment! |
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 |
time.pl: |
|---|
| 569 |
-------- |
|---|
| 570 |
|
|---|
| 571 |
This code snippet shows you different ways of how to access the current |
|---|
| 572 |
date and time, both as Greenwich Mean Time as well as local time. |
|---|
| 573 |
|
|---|
| 574 |
Just run this example with "perl time.pl": |
|---|
| 575 |
|
|---|
| 576 |
:> perl time.pl |
|---|
| 577 |
Today_and_Now(0) = Fri 16-Mar-2001 16:07:15 |
|---|
| 578 |
Today_and_Now(1) = Fri 16-Mar-2001 15:07:15 |
|---|
| 579 |
Add_Delta_DHMS(984755235) = Fri 16-Mar-2001 15:07:15 |
|---|
| 580 |
gmtime(984755235) = Fri 16-Mar-2001 15:07:15 |
|---|
| 581 |
localtime(984755235) = Fri 16-Mar-2001 16:07:15 |
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 |
vacation.pl: |
|---|
| 585 |
------------ |
|---|
| 586 |
|
|---|
| 587 |
This program shows how to calculate the number of holidays you have |
|---|
| 588 |
to debit from your account of (paid) vacation days whenever you |
|---|
| 589 |
apply for some vacation. |
|---|
| 590 |
|
|---|
| 591 |
The program does not take any command-line parameters, because you |
|---|
| 592 |
will have to adjust the holidays profile used anyway, and therefore, |
|---|
| 593 |
the start and end date of your vacation are hard-coded, in this |
|---|
| 594 |
example. |
|---|
| 595 |
|
|---|
| 596 |
Just start this program with "perl vacation.pl" and it will print |
|---|
| 597 |
the number of workdays covered by your vacation (including both |
|---|
| 598 |
the start and end date, if applicable): |
|---|
| 599 |
|
|---|
| 600 |
:> perl vacation.pl |
|---|
| 601 |
23 |
|---|
| 602 |
|
|---|
| 603 |
|
|---|
| 604 |
weiberfastnacht.pl: |
|---|
| 605 |
------------------- |
|---|
| 606 |
|
|---|
| 607 |
This little script demonstrates how you can search for dates by name, |
|---|
| 608 |
and how you can poll all the names associated with any particular date. |
|---|
| 609 |
|
|---|
| 610 |
Moreover, it shows how the cache of Date::Calendar objects works, and |
|---|
| 611 |
how it can be manipulated. |
|---|
| 612 |
|
|---|
| 613 |
Please see the script's code for more details. |
|---|
| 614 |
|
|---|
| 615 |
Sample run: |
|---|
| 616 |
|
|---|
| 617 |
:> perl weiberfastnacht.pl |
|---|
| 618 |
Donnerstag, den 2. März 2000 (Donnerstag Fettdonnerstag Weiberfastnacht) |
|---|
| 619 |
Donnerstag, den 22. Februar 2001 (Donnerstag Fettdonnerstag Weiberfastnacht) |
|---|
| 620 |
Donnerstag, den 7. Februar 2002 (Donnerstag Fettdonnerstag Weiberfastnacht) |
|---|
| 621 |
Donnerstag, den 27. Februar 2003 (Donnerstag Fettdonnerstag Weiberfastnacht) |
|---|
| 622 |
|
|---|
| 623 |
Donnerstag, den 19. Februar 2004 (Donnerstag Fettdonnerstag Weiberfastnacht) |
|---|
| 624 |
|
|---|
| 625 |
(The script searches for the dates of the Thursday before Carnival in the |
|---|
| 626 |
years 2000 through 2004, and prints the results.) |
|---|
| 627 |
|
|---|
| 628 |
|
|---|