Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | .\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "CALENDAR 1" | |
132 | .TH CALENDAR 1 "2002-09-28" "perl v5.8.0" "User Contributed Perl Documentation" | |
133 | .SH "NAME" | |
134 | Date::Calendar \- Calendar objects for different holiday schemes | |
135 | .SH "MOTTO" | |
136 | .IX Header "MOTTO" | |
137 | There is more than one way to do it \- this is just one of them! | |
138 | .SH "PREFACE" | |
139 | .IX Header "PREFACE" | |
140 | Basically, Date::Calendar is just a caching proxy class for | |
141 | Date::Calendar::Year objects, which are embedded in each | |
142 | Date::Calendar object. | |
143 | .PP | |
144 | However, and in contrast to Date::Calendar::Year methods, Date::Calendar | |
145 | methods permit calculations spanning an arbitrary number of years, without | |
146 | loss of efficiency. | |
147 | .PP | |
148 | So you should usually use Date::Calendar and not Date::Calendar::Year, | |
149 | since that way you don't have to worry about calculations crossing year | |
150 | boundaries. | |
151 | .PP | |
152 | Note however that Date::Calendar and Date::Calendar::Year can only deal | |
153 | with years lying within the range [1583..2299]. | |
154 | .SH "SYNOPSIS" | |
155 | .IX Header "SYNOPSIS" | |
156 | .Vb 2 | |
157 | \& use Date::Calendar::Profiles qw( $Profiles ); | |
158 | \& use Date::Calendar; | |
159 | .Ve | |
160 | .PP | |
161 | .Vb 2 | |
162 | \& $calendar_US_AZ = Date::Calendar->new( $Profiles->{'US-AZ'} [,LANG] ); | |
163 | \& $calendar_DE_SN = Date::Calendar->new( $Profiles->{'DE-SN'} [,LANG] ); | |
164 | .Ve | |
165 | .PP | |
166 | .Vb 2 | |
167 | \& $year_2000_US_AZ = $calendar_US_AZ->year( 2000 ); | |
168 | \& $year_2001_DE_SN = $calendar_DE_SN->year( 2001 ); | |
169 | .Ve | |
170 | .PP | |
171 | .Vb 2 | |
172 | \& @years = $calendar->cache_keys(); # returns list of year numbers | |
173 | \& @years = $calendar->cache_vals(); # returns list of year objects | |
174 | .Ve | |
175 | .PP | |
176 | .Vb 3 | |
177 | \& $calendar->cache_clr(); | |
178 | \& $calendar->cache_add(YEAR|DATE,...); | |
179 | \& $calendar->cache_del(YEAR|DATE,...); | |
180 | .Ve | |
181 | .PP | |
182 | .Vb 1 | |
183 | \& $index = $calendar->date2index(YEAR,MONTH,DAY|DATE); | |
184 | .Ve | |
185 | .PP | |
186 | .Vb 3 | |
187 | \& @names = $calendar->labels(YEAR,MONTH,DAY|DATE); | |
188 | \& @holidays = $calendar->labels(); | |
189 | \& $holidays = $calendar->labels(); | |
190 | .Ve | |
191 | .PP | |
192 | .Vb 2 | |
193 | \& @dates = $calendar->search(PATTERN); | |
194 | \& $dates = $calendar->search(PATTERN); | |
195 | .Ve | |
196 | .PP | |
197 | .Vb 3 | |
198 | \& $days = $calendar->delta_workdays(YEAR1,MONTH1,DAY1|DATE1 | |
199 | \& ,YEAR2,MONTH2,DAY2|DATE2 | |
200 | \& ,FLAG1,FLAG2); | |
201 | .Ve | |
202 | .PP | |
203 | .Vb 4 | |
204 | \& ($date,$rest) = $calendar->add_delta_workdays(YEAR,MONTH,DAY|DATE | |
205 | \& ,DELTA); | |
206 | \& $date = $calendar->add_delta_workdays(YEAR,MONTH,DAY|DATE | |
207 | \& ,DELTA); | |
208 | .Ve | |
209 | .PP | |
210 | .Vb 3 | |
211 | \& $flag = $calendar->is_full(YEAR,MONTH,DAY|DATE); | |
212 | \& $flag = $calendar->is_half(YEAR,MONTH,DAY|DATE); | |
213 | \& $flag = $calendar->is_work(YEAR,MONTH,DAY|DATE); | |
214 | .Ve | |
215 | .SH "INTERFACE" | |
216 | .IX Header "INTERFACE" | |
217 | Note that whenever a year number, a date, a time or a combined | |
218 | date and time are expected as input parameters by one of the | |
219 | methods of this class, you can always pass a Date::Calc[::Object] | |
220 | date object or an array reference (of an array of appropriate | |
221 | length) instead! | |
222 | .PP | |
223 | See \fIDate::Calc::Object\fR\|(3) for more details. | |
224 | .PP | |
225 | So instead of calling a given method like this: | |
226 | .PP | |
227 | .Vb 3 | |
228 | \& $object->method1( $year,$month,$day ); | |
229 | \& $object->method2( $year1,$month1,$day1, $year2,$month2,$day2 ); | |
230 | \& $object->method3( $year1, $year2, $year3 ); | |
231 | .Ve | |
232 | .PP | |
233 | You can also call it like so: | |
234 | .PP | |
235 | .Vb 2 | |
236 | \& $object->method1( $date ); | |
237 | \& $object->method1( [1964,1,3] ); | |
238 | .Ve | |
239 | .PP | |
240 | .Vb 8 | |
241 | \& $object->method2( $year1,$month1,$day1, $date2 ); | |
242 | \& $object->method2( $date1, $year2,$month2,$day2 ); | |
243 | \& $object->method2( $date1, $date2 ); | |
244 | \& $object->method2( $year1,$month1,$day1, [2001,3,17] ); | |
245 | \& $object->method2( [1964,1,3], $year2,$month2,$day2 ); | |
246 | \& $object->method2( [1964,1,3], [2001,3,17] ); | |
247 | \& $object->method2( $date1, [2001,3,17] ); | |
248 | \& $object->method2( [1964,1,3], $date2 ); | |
249 | .Ve | |
250 | .PP | |
251 | .Vb 1 | |
252 | \& $object->method3( $year1, $date2, [2001,3,17] ); | |
253 | .Ve | |
254 | .PP | |
255 | And similarly if a time or a combined date and time are expected. | |
256 | .PP | |
257 | If you substitute an expected year number by an anonymous array | |
258 | (this is the recommended way of writing date constants, for | |
259 | increased readability of your programs), it must contain three | |
260 | values, nevertheless (otherwise the use of an anonymous array | |
261 | would be pointless). | |
262 | .PP | |
263 | Don't confuse year numbers and their substitutes (a date object | |
264 | or an array reference) with Date::Calendar::Year objects, which | |
265 | are a totally different thing! | |
266 | .PP | |
267 | But incidentally \f(CW\*(C`:\-)\*(C'\fR, you may also pass a Date::Calendar::Year | |
268 | object whenever a year number is expected. However, and perhaps | |
269 | against your expectations at times, especially in conjunction | |
270 | with the method \*(L"\fIcache_add()\fR\*(R", only the year number from that | |
271 | object will be used, not the year object itself (the year | |
272 | object in question might be using the wrong profile!). | |
273 | .PP | |
274 | Moreover, whenever a method of this class returns a date, it | |
275 | does so by returning a Date::Calc[::Object] date object. | |
276 | .SH "DESCRIPTION" | |
277 | .IX Header "DESCRIPTION" | |
278 | .IP "\(bu" 2 | |
279 | \&\f(CW\*(C`$calendar = Date::Calendar\->new(PROFILE[,LANG]);\*(C'\fR | |
280 | .Sp | |
281 | The first argument must be the reference of a hash, | |
282 | which contains a holiday scheme or \*(L"profile\*(R" to be used | |
283 | in all calculations involving the new calendar object. | |
284 | .Sp | |
285 | The second argument is optional, and must consist of | |
286 | the valid name or number of a language as provided by | |
287 | the \fIDate::Calc\fR\|(3) module if given. | |
288 | .Sp | |
289 | See \fIDate::Calendar::Profiles\fR\|(3) and \fIDate::Calendar::Year\fR\|(3) | |
290 | for more details about these arguments and about how | |
291 | to roll your own calendar profiles. | |
292 | .Sp | |
293 | The method creates a new calendar object for a given profile, | |
294 | i.e., a given location and its scheme of holidays (or a scheme | |
295 | of your own). | |
296 | .Sp | |
297 | This calendar object is a caching proxy object; it stores the | |
298 | reference of the given profile and contains a hash (the cache) | |
299 | of Date::Calendar::Year objects. | |
300 | .IP "\(bu" 2 | |
301 | \&\f(CW\*(C`$year = $calendar\->year(YEAR|DATE);\*(C'\fR | |
302 | .Sp | |
303 | This method returns a Date::Calendar::Year object for the given | |
304 | year and the profile that was associated with the given calendar | |
305 | object. | |
306 | .Sp | |
307 | If the cache in the given calendar object already contains an | |
308 | object for the requested year, the corresponding object reference | |
309 | is simply returned. | |
310 | .Sp | |
311 | If not, a new Date::Calendar::Year object is created using the | |
312 | profile that has been associated with the given calendar object. | |
313 | The new Date::Calendar::Year object is then stored in the calendar | |
314 | object's cache and its object reference is returned. | |
315 | .Sp | |
316 | A fatal \*(L"given year out of range\*(R" error will occur if the given | |
317 | year number lies outside the valid range of [1583..2299]. | |
318 | .IP "\(bu" 2 | |
319 | \&\f(CW\*(C`@years = $calendar\->cache_keys();\*(C'\fR | |
320 | .Sp | |
321 | This method returns the list of \fB\s-1YEAR\s0 \s-1NUMBERS\s0\fR of the | |
322 | Date::Calendar::Year objects contained in the given | |
323 | calendar object's cache. | |
324 | .IP "\(bu" 2 | |
325 | \&\f(CW\*(C`@years = $calendar\->cache_vals();\*(C'\fR | |
326 | .Sp | |
327 | This method returns the list of \fB\s-1OBJECT\s0 \s-1REFERENCES\s0\fR of | |
328 | the Date::Calendar::Year objects contained in the given | |
329 | calendar object's cache. | |
330 | .IP "\(bu" 2 | |
331 | \&\f(CW\*(C`$calendar\->cache_clr();\*(C'\fR | |
332 | .Sp | |
333 | This method clears the entire cache of the given calendar | |
334 | object (by destroying the cache hash and creating a new one). | |
335 | .IP "\(bu" 2 | |
336 | \&\f(CW\*(C`$calendar\->cache_add(YEAR|DATE,...);\*(C'\fR | |
337 | .Sp | |
338 | Roughly, this method is a shortcut for | |
339 | .Sp | |
340 | .Vb 4 | |
341 | \& for $year (@list) | |
342 | \& { | |
343 | \& $calendar->year($year); | |
344 | \& } | |
345 | .Ve | |
346 | .IP "\(bu" 2 | |
347 | \&\f(CW\*(C`$calendar\->cache_del(YEAR|DATE,...);\*(C'\fR | |
348 | .Sp | |
349 | This method removes the Date::Calendar::Year objects whose | |
350 | year numbers are given from the cache of the given calendar | |
351 | object. | |
352 | .Sp | |
353 | Year numbers for which the calendar object's cache doesn't | |
354 | contain an entry are simply ignored. | |
355 | .IP "\(bu" 2 | |
356 | \&\f(CW\*(C`$index = $calendar\->date2index(YEAR,MONTH,DAY|DATE);\*(C'\fR | |
357 | .Sp | |
358 | This method converts a given date into the number of the day in | |
359 | that year (this is sometimes also referred to as the \*(L"julian\*(R" | |
360 | date), i.e., a number between 0 (for January 1st) and the number | |
361 | of days in the given year minus one, i.e., 364 or 365 (for | |
362 | December 31st). | |
363 | .Sp | |
364 | You may need this in order to access the bit vectors returned | |
365 | by the Date::Calendar::Year methods \*(L"\fIvec_full()\fR\*(R", \*(L"\fIvec_half()\fR\*(R" | |
366 | and \*(L"\fIvec_work()\fR\*(R". | |
367 | .Sp | |
368 | If the Date::Calendar::Year object for the given \s-1YEAR\s0 is not in | |
369 | the \f(CW$calendar\fR's cache yet, it will be created and added. | |
370 | .Sp | |
371 | An exception (\*(L"invalid date\*(R") is thrown if the given arguments | |
372 | do not constitute a valid date, or (\*(L"given year out of range | |
373 | [1583..2299]\*(R") if the given year lies outside of the permitted | |
374 | range. | |
375 | .IP "\(bu" 2 | |
376 | \&\f(CW\*(C`@names = $calendar\->labels(YEAR,MONTH,DAY|DATE);\*(C'\fR | |
377 | .Sp | |
378 | \&\f(CW\*(C`@holidays = $calendar\->labels();\*(C'\fR | |
379 | .Sp | |
380 | \&\f(CW\*(C`$holidays = $calendar\->labels();\*(C'\fR | |
381 | .Sp | |
382 | If any arguments are given, they are supposed to represent a | |
383 | date. In that case, a list of all labels (= names of holidays) | |
384 | associated with that date are returned. The first item returned | |
385 | is always the name of the day of week for that date. The | |
386 | corresponding year object for the given date's year is | |
387 | added to the calendar's cache first if necessary. | |
388 | .Sp | |
389 | If no arguments are given, the list of all available labels in | |
390 | all years that have previously been accessed in the given calendar | |
391 | (i.e., the years which are already in the given calendar's cache) | |
392 | is constructed. Note that this means that the returned list will | |
393 | be empty if there are no year objects in the given calendar's | |
394 | cache yet (!). The returned list does \fB\s-1NOT\s0\fR include any names | |
395 | of the days of week (which would be pointless in this case). | |
396 | .Sp | |
397 | Multiple labels are reported only once. | |
398 | .Sp | |
399 | Usually all years have the same set of labels, so it may seem | |
400 | superfluous to scan all the years in the cache instead of just | |
401 | one. But there may be exceptions, because it is possible to | |
402 | define calendar profiles which do not contain all possible | |
403 | holidays in every year. See \fIDate::Calendar::Profiles\fR\|(3) | |
404 | and \fIDate::Calendar::Year\fR\|(3) for more details. | |
405 | .Sp | |
406 | In list context, the resulting list itself is returned. In scalar | |
407 | context, the number of items in the resulting list is returned. | |
408 | .IP "\(bu" 2 | |
409 | \&\f(CW\*(C`@dates = $calendar\->search(PATTERN);\*(C'\fR | |
410 | .Sp | |
411 | \&\f(CW\*(C`$dates = $calendar\->search(PATTERN);\*(C'\fR | |
412 | .Sp | |
413 | This method searches through all the labels in all years that | |
414 | have previously been accessed in the given calendar (i.e., the | |
415 | years which are already in the given calendar's cache) and | |
416 | returns a list of date objects with all dates whose labels | |
417 | match the given pattern. | |
418 | .Sp | |
419 | (Use the methods \*(L"\fIcache_clr()\fR\*(R", \*(L"\fIcache_add()\fR\*(R" and \*(L"\fIcache_del()\fR\*(R" | |
420 | in order to put the year numbers you want into the calendar | |
421 | object's cache, or to make sure it only contains the year | |
422 | numbers you want to search.) | |
423 | .Sp | |
424 | Note that this is a simple, case-insensitive substring search, | |
425 | \&\fB\s-1NOT\s0\fR a full-fledged regular expression search! | |
426 | .Sp | |
427 | The result is guaranteed to be sorted chronologically. | |
428 | .Sp | |
429 | In scalar context, only the number of items in the resulting list | |
430 | is returned, instead of the resulting list itself (as in list context). | |
431 | .IP "\(bu" 2 | |
432 | \&\f(CW\*(C`$days = $calendar\->delta_workdays(YEAR1,MONTH1,DAY1, YEAR2,MONTH2,DAY2, FLAG1,FLAG2);\*(C'\fR | |
433 | .Sp | |
434 | \&\f(CW\*(C`$days = $calendar\->delta_workdays(DATE1,DATE2,FLAG1,FLAG2);\*(C'\fR | |
435 | .Sp | |
436 | This method calculates the number of work days (i.e., the number | |
437 | of days, but excluding all holidays) between two dates. | |
438 | .Sp | |
439 | In other words, this method is equivalent to the \*(L"\fIDelta_Days()\fR\*(R" | |
440 | function of the Date::Calc module, except that it disregards | |
441 | holidays in its counting. | |
442 | .Sp | |
443 | The two flags indicate whether the start and end dates should be | |
444 | included in the counting (that is, of course, only in case they | |
445 | aren't holidays), or not. | |
446 | .Sp | |
447 | It is common, for example, that you want to know how many work | |
448 | days are left between the current date and a given deadline. | |
449 | .Sp | |
450 | Typically, you will want to count the current date but not the | |
451 | deadline's date. So you would specify \*(L"true\*(R" (\*(L"1\*(R") for \s-1FLAG1\s0 | |
452 | and \*(L"false\*(R" (\*(L"0\*(R") for \s-1FLAG2\s0 in order to achieve that. | |
453 | .Sp | |
454 | In other words, a value of \*(L"true\*(R" means \*(L"including this date\*(R", | |
455 | a value of \*(L"false\*(R" means \*(L"excluding this date\*(R". | |
456 | .Sp | |
457 | As with the \*(L"\fIDelta_Days()\fR\*(R" function from the Date::Calc module, | |
458 | the dates have to be given in chronological order to yield a | |
459 | positive result. If the dates are reversed, the result will | |
460 | be negative. | |
461 | .Sp | |
462 | The parameter \s-1FLAG1\s0 is associated with the first given date, | |
463 | the parameter \s-1FLAG2\s0 with the second given date (regardless | |
464 | of whether the dates are in chronological order or not). | |
465 | .Sp | |
466 | An exception (\*(L"invalid date\*(R") is raised if either of the two | |
467 | date arguments does not constitute a valid date. | |
468 | .IP "\(bu" 2 | |
469 | \&\f(CW\*(C`($date,$rest) = $calendar\->add_delta_workdays(YEAR,MONTH,DAY, DELTA);\*(C'\fR | |
470 | .Sp | |
471 | \&\f(CW\*(C`($date,$rest) = $calendar\->add_delta_workdays(DATE,DELTA);\*(C'\fR | |
472 | .Sp | |
473 | \&\f(CW\*(C`$date = $calendar\->add_delta_workdays(YEAR,MONTH,DAY, DELTA);\*(C'\fR | |
474 | .Sp | |
475 | \&\f(CW\*(C`$date = $calendar\->add_delta_workdays(DATE,DELTA);\*(C'\fR | |
476 | .Sp | |
477 | This method is the equivalent of the \*(L"\fIAdd_Delta_Days()\fR\*(R" function | |
478 | from the Date::Calc module, except that it adds work days and | |
479 | skips holidays. | |
480 | .Sp | |
481 | In other words, you can add or subtract a number of work days | |
482 | \&\*(L"\s-1DELTA\s0\*(R" to/from a given date and get a new date as the result | |
483 | (as a Date::Calc object). | |
484 | .Sp | |
485 | You add days (i.e., you go forward in time) with a positive | |
486 | offset \*(L"\s-1DELTA\s0\*(R", and you subtract days (i.e., you go backwards | |
487 | in time) with a negative offset. | |
488 | .Sp | |
489 | Note that an exception (\*(L"invalid date\*(R") is raised if the | |
490 | given date argument does not constitute a valid date. | |
491 | .Sp | |
492 | In scalar context, the method just returns the resulting date | |
493 | object, whereas in list context the method not only returns the | |
494 | new date, but also a \*(L"rest\*(R". This rest is useful for cases in | |
495 | which your profile contains \*(L"half\*(R" holidays, or when you add | |
496 | or subtract fractions of a day. | |
497 | .Sp | |
498 | Sometimes it is not possible to accomodate the requested number | |
499 | of work days, and a rest remains. | |
500 | .Sp | |
501 | This rest can currently only assume the value \*(L"0.0\*(R" (zero), | |
502 | \&\*(L"\-0.5\*(R" (minus one half) or \*(L"0.5\*(R" (one half), provided you | |
503 | use only integral or multiples of 0.5 as offsets. A rest | |
504 | of zero indicates that the calculation yielded an exact | |
505 | result. If the rest is 0.5 or \-0.5, this is to be interpreted | |
506 | as \*(L"the resulting date at 12:00 o'clock\*(R", instead of as \*(L"the | |
507 | resulting date at 0:00 o'clock\*(R". | |
508 | .Sp | |
509 | The rest is always positive (or zero) if the offset \*(L"\s-1DELTA\s0\*(R" | |
510 | is positive (or zero), and always negative (or zero) if the | |
511 | offset is negative (or zero). | |
512 | .Sp | |
513 | Example: | |
514 | .Sp | |
515 | .Vb 9 | |
516 | \& #!perl | |
517 | \& use Date::Calendar; | |
518 | \& use Date::Calendar::Profiles qw( $Profiles ); | |
519 | \& $year = shift; | |
520 | \& $cal = Date::Calendar->new( $Profiles->{'sdm-MUC'} ); | |
521 | \& ($date,$rest) = $cal->add_delta_workdays($year,1,3, -3); | |
522 | \& $date->date_format(1); | |
523 | \& print "\e$date = $date, \e$rest = $rest.\en"; | |
524 | \& __END__ | |
525 | .Ve | |
526 | .Sp | |
527 | This program calculates \*(L"January 3rd of the given year minus | |
528 | 3 work days\*(R": | |
529 | .Sp | |
530 | .Vb 4 | |
531 | \& > perl test.pl 2001 | |
532 | \& $date = 28-Dec-2000, $rest = 0. | |
533 | \& > perl test.pl 2002 | |
534 | \& $date = 28-Dec-2001, $rest = -0.5. | |
535 | .Ve | |
536 | .Sp | |
537 | Note that December 31st is a \*(L"half\*(R" holiday in 2001 for the | |
538 | calendar profile used in this example. | |
539 | .Sp | |
540 | You can easily verify the results above with the help of the | |
541 | \&\*(L"calendar.cgi\*(R" \s-1CGI\s0 script or the \*(L"linearcal.pl\*(R" script from | |
542 | the \*(L"examples\*(R" subdirectory in the Date::Calc distribution. | |
543 | .IP "\(bu" 2 | |
544 | \&\f(CW\*(C`$flag = $calendar\->is_full(YEAR,MONTH,DAY|DATE);\*(C'\fR | |
545 | .Sp | |
546 | This method returns \*(L"true\*(R" (\*(L"1\*(R") if the bit corresponding to | |
547 | the given date is set in the bit vector representing \*(L"full\*(R" | |
548 | holidays, and \*(L"false\*(R" (\*(L"0\*(R") otherwise. | |
549 | .Sp | |
550 | I.e., the method returns \*(L"true\*(R" if the given date is a (full) | |
551 | holiday (according to the calendar profile associated with the | |
552 | given calendar object). | |
553 | .Sp | |
554 | The corresponding Date::Calendar::Year object is created first | |
555 | and stored in the calendar object's cache if necessary (if it's | |
556 | not already there). | |
557 | .Sp | |
558 | Note that you can get a reference to this bit vector (in order | |
559 | to use this bit vector in bit vector operations) as follows: | |
560 | .Sp | |
561 | .Vb 1 | |
562 | \& $vec_full = $calendar->year($year)->vec_full(); | |
563 | .Ve | |
564 | .Sp | |
565 | The number of bits in this bit vector is the same as the number | |
566 | of days in the given year "\f(CW$year\fR\*(L", which you can retrieve | |
567 | through either \*(R"\f(CW\*(C`$days = $vec_full\->Size();\*(C'\fR\*(L" or | |
568 | \&\*(R"\f(CW\*(C`$days = $year\->val_days();\*(C'\fR". | |
569 | .Sp | |
570 | See \fIDate::Calendar::Year\fR\|(3) and \fIBit::Vector\fR\|(3) for more | |
571 | details. | |
572 | .IP "\(bu" 2 | |
573 | \&\f(CW\*(C`$flag = $calendar\->is_half(YEAR,MONTH,DAY|DATE);\*(C'\fR | |
574 | .Sp | |
575 | This method returns \*(L"true\*(R" (\*(L"1\*(R") if the bit corresponding to | |
576 | the given date is set in the bit vector representing \*(L"half\*(R" | |
577 | holidays, and \*(L"false\*(R" (\*(L"0\*(R") otherwise. | |
578 | .Sp | |
579 | I.e., the method returns \*(L"true\*(R" if the given date is a half | |
580 | holiday (according to the calendar profile associated with the | |
581 | given calendar object). | |
582 | .Sp | |
583 | Note that if a date is a \*(L"full\*(R" holiday, the \*(L"half\*(R" bit is | |
584 | never set, even if you try to do so in your calendar profile, | |
585 | on purpose or by accident. | |
586 | .Sp | |
587 | The corresponding Date::Calendar::Year object is created first | |
588 | and stored in the calendar object's cache if necessary (if it's | |
589 | not already there). | |
590 | .Sp | |
591 | Note that you can get a reference to this bit vector (in order | |
592 | to use this bit vector in bit vector operations) as follows: | |
593 | .Sp | |
594 | .Vb 1 | |
595 | \& $vec_half = $calendar->year($year)->vec_half(); | |
596 | .Ve | |
597 | .Sp | |
598 | The number of bits in this bit vector is the same as the number | |
599 | of days in the given year "\f(CW$year\fR\*(L", which you can retrieve | |
600 | through either \*(R"\f(CW\*(C`$days = $vec_half\->Size();\*(C'\fR\*(L" or | |
601 | \&\*(R"\f(CW\*(C`$days = $year\->val_days();\*(C'\fR". | |
602 | .Sp | |
603 | See \fIDate::Calendar::Year\fR\|(3) and \fIBit::Vector\fR\|(3) for more | |
604 | details. | |
605 | .IP "\(bu" 2 | |
606 | \&\f(CW\*(C`$flag = $calendar\->is_work(YEAR,MONTH,DAY|DATE);\*(C'\fR | |
607 | .Sp | |
608 | This method returns \*(L"true\*(R" (\*(L"1\*(R") if the bit corresponding to | |
609 | the given date is set in the bit vector used to perform all | |
610 | sorts of calculations, and \*(L"false\*(R" (\*(L"0\*(R") otherwise. | |
611 | .Sp | |
612 | The corresponding Date::Calendar::Year object is created first | |
613 | and stored in the calendar object's cache if necessary (if it's | |
614 | not already there). | |
615 | .Sp | |
616 | \&\fB\s-1BEWARE\s0\fR that the \*(L"work\*(R" in this method's name does \fB\s-1NOT\s0\fR | |
617 | come from \*(L"work days\*(R"! | |
618 | .Sp | |
619 | It comes from the fact that the corresponding bit vector can | |
620 | be used for any \*(L"work\*(R" that you need to do. In other words, | |
621 | it's a \*(L"work space\*(R". | |
622 | .Sp | |
623 | Therefore, this bit vector might contain about everything you | |
624 | could imagine \- including a bit pattern which marks all \*(L"work | |
625 | days\*(R" with set bits, if it so happens! | |
626 | .Sp | |
627 | But you better don't rely on it, unless you put the bit pattern | |
628 | there yourself in the first place. | |
629 | .Sp | |
630 | Note that you can get a reference to this bit vector (in order | |
631 | to fill it with any bit pattern you like) as follows: | |
632 | .Sp | |
633 | .Vb 1 | |
634 | \& $vec_work = $calendar->year($year)->vec_work(); | |
635 | .Ve | |
636 | .Sp | |
637 | The number of bits in this bit vector is the same as the number | |
638 | of days in the given year "\f(CW$year\fR\*(L", which you can retrieve | |
639 | through either \*(R"\f(CW\*(C`$days = $vec_work\->Size();\*(C'\fR\*(L" or | |
640 | \&\*(R"\f(CW\*(C`$days = $year\->val_days();\*(C'\fR". | |
641 | .Sp | |
642 | See \fIDate::Calendar::Year\fR\|(3) and \fIBit::Vector\fR\|(3) for more | |
643 | details. | |
644 | .SH "SEE ALSO" | |
645 | .IX Header "SEE ALSO" | |
646 | \&\fIDate::Calendar::Year\fR\|(3), \fIDate::Calendar::Profiles\fR\|(3), | |
647 | \&\fIDate::Calc::Object\fR\|(3), \fIDate::Calc\fR\|(3), \fIBit::Vector\fR\|(3). | |
648 | .SH "VERSION" | |
649 | .IX Header "VERSION" | |
650 | This man page documents \*(L"Date::Calendar\*(R" version 5.3. | |
651 | .SH "AUTHOR" | |
652 | .IX Header "AUTHOR" | |
653 | .Vb 3 | |
654 | \& Steffen Beyer | |
655 | \& mailto:sb@engelschall.com | |
656 | \& http://www.engelschall.com/u/sb/download/ | |
657 | .Ve | |
658 | .SH "COPYRIGHT" | |
659 | .IX Header "COPYRIGHT" | |
660 | Copyright (c) 2000 \- 2002 by Steffen Beyer. All rights reserved. | |
661 | .SH "LICENSE" | |
662 | .IX Header "LICENSE" | |
663 | This package is free software; you can redistribute it and/or | |
664 | modify it under the same terms as Perl itself, i.e., under the | |
665 | terms of the \*(L"Artistic License\*(R" or the \*(L"\s-1GNU\s0 General Public License\*(R". | |
666 | .PP | |
667 | Please refer to the files \*(L"Artistic.txt\*(R" and \*(L"\s-1GNU_GPL\s0.txt\*(R" | |
668 | in this distribution for details! | |
669 | .SH "DISCLAIMER" | |
670 | .IX Header "DISCLAIMER" | |
671 | This package is distributed in the hope that it will be useful, | |
672 | but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of | |
673 | \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. | |
674 | .PP | |
675 | See the \*(L"\s-1GNU\s0 General Public License\*(R" for more details. |