| 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 "YEAR 1" |
| 132 | .TH YEAR 1 "2002-09-28" "perl v5.8.0" "User Contributed Perl Documentation" |
| 133 | .SH "NAME" |
| 134 | Date::Calendar::Year \- Implements embedded "year" objects for Date::Calendar |
| 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 | Note that Date::Calendar::Year (and Date::Calendar) can only deal |
| 141 | with years lying within the range [1583..2299]. |
| 142 | .SH "SYNOPSIS" |
| 143 | .IX Header "SYNOPSIS" |
| 144 | .Vb 2 |
| 145 | \& use Date::Calendar::Year qw( check_year empty_period ); |
| 146 | \& use Date::Calendar::Year qw( :all ); # same as above |
| 147 | .Ve |
| 148 | .PP |
| 149 | .Vb 2 |
| 150 | \& check_year(YEAR|DATE); # dies if year < 1583 or year > 2299 |
| 151 | \& empty_period(); # warns about empty interval if $^W is set |
| 152 | .Ve |
| 153 | .PP |
| 154 | .Vb 2 |
| 155 | \& $index = $year->date2index(YEAR,MONTH,DAY|DATE); |
| 156 | \& $date = $year->index2date(INDEX); |
| 157 | .Ve |
| 158 | .PP |
| 159 | .Vb 3 |
| 160 | \& use Date::Calendar::Profiles qw( $Profiles ); |
| 161 | \& $year_2000_US_FL = Date::Calendar::Year->new( 2000, $Profiles->{'US-FL'} [,LANG] ); |
| 162 | \& $year_2001_DE_NW = Date::Calendar::Year->new( 2001, $Profiles->{'DE-NW'} [,LANG] ); |
| 163 | .Ve |
| 164 | .PP |
| 165 | .Vb 2 |
| 166 | \& $year = Date::Calendar::Year->new( 2001, {} ); |
| 167 | \& $year->init( 2002, $Profiles->{'DE-SN'} [,LANG] ); |
| 168 | .Ve |
| 169 | .PP |
| 170 | .Vb 7 |
| 171 | \& $vector = $year->vec_full(); # vector of full holidays |
| 172 | \& $vector = $year->vec_half(); # vector of half holidays |
| 173 | \& $vector = $year->vec_work(); # NOT a vector of workdays but a workspace! |
| 174 | \& $size = $year->val_days(); # number of days in that year, size of vectors |
| 175 | \& $base = $year->val_base(); # number of days for [year,1,1] since [1,1,1] |
| 176 | \& $number = $year->val_year(); # the year's number itself |
| 177 | \& $number = $year->year(); # alias for val_year() |
| 178 | .Ve |
| 179 | .PP |
| 180 | .Vb 3 |
| 181 | \& @names = $year->labels(YEAR,MONTH,DAY|DATE); |
| 182 | \& @holidays = $year->labels(); |
| 183 | \& $holidays = $year->labels(); |
| 184 | .Ve |
| 185 | .PP |
| 186 | .Vb 2 |
| 187 | \& @dates = $year->search(PATTERN); |
| 188 | \& $dates = $year->search(PATTERN); |
| 189 | .Ve |
| 190 | .PP |
| 191 | .Vb 3 |
| 192 | \& $days = $year->delta_workdays(YEAR,MONTH1,DAY1|DATE1 |
| 193 | \& ,YEAR,MONTH2,DAY2|DATE2 |
| 194 | \& ,FLAG1,FLAG2); |
| 195 | .Ve |
| 196 | .PP |
| 197 | .Vb 2 |
| 198 | \& ($date,$rest,$sign) = $year->add_delta_workdays(YEAR,MONTH,DAY|DATE |
| 199 | \& ,DELTA,SIGN); |
| 200 | .Ve |
| 201 | .PP |
| 202 | .Vb 3 |
| 203 | \& $flag = $year->is_full(YEAR,MONTH,DAY|DATE); |
| 204 | \& $flag = $year->is_half(YEAR,MONTH,DAY|DATE); |
| 205 | \& $flag = $year->is_work(YEAR,MONTH,DAY|DATE); |
| 206 | .Ve |
| 207 | .SH "INTERFACE" |
| 208 | .IX Header "INTERFACE" |
| 209 | Note that whenever a year number, a date, a time or a combined |
| 210 | date and time are expected as input parameters by one of the |
| 211 | methods of this class, you can always pass a Date::Calc[::Object] |
| 212 | date object or an array reference (of an array of appropriate |
| 213 | length) instead! |
| 214 | .PP |
| 215 | See \fIDate::Calc::Object\fR\|(3) for more details. |
| 216 | .PP |
| 217 | So instead of calling a given method like this: |
| 218 | .PP |
| 219 | .Vb 3 |
| 220 | \& $object->method1( $year,$month,$day ); |
| 221 | \& $object->method2( $year1,$month1,$day1, $year2,$month2,$day2 ); |
| 222 | \& $object->method3( $year1, $year2, $year3 ); |
| 223 | .Ve |
| 224 | .PP |
| 225 | You can also call it like so: |
| 226 | .PP |
| 227 | .Vb 2 |
| 228 | \& $object->method1( $date ); |
| 229 | \& $object->method1( [1964,1,3] ); |
| 230 | .Ve |
| 231 | .PP |
| 232 | .Vb 8 |
| 233 | \& $object->method2( $year1,$month1,$day1, $date2 ); |
| 234 | \& $object->method2( $date1, $year2,$month2,$day2 ); |
| 235 | \& $object->method2( $date1, $date2 ); |
| 236 | \& $object->method2( $year1,$month1,$day1, [2001,3,17] ); |
| 237 | \& $object->method2( [1964,1,3], $year2,$month2,$day2 ); |
| 238 | \& $object->method2( [1964,1,3], [2001,3,17] ); |
| 239 | \& $object->method2( $date1, [2001,3,17] ); |
| 240 | \& $object->method2( [1964,1,3], $date2 ); |
| 241 | .Ve |
| 242 | .PP |
| 243 | .Vb 1 |
| 244 | \& $object->method3( $year1, $date2, [2001,3,17] ); |
| 245 | .Ve |
| 246 | .PP |
| 247 | And similarly if a time or a combined date and time are expected. |
| 248 | .PP |
| 249 | If you substitute an expected year number by an anonymous array |
| 250 | (this is the recommended way of writing date constants, for |
| 251 | increased readability of your programs), it must contain three |
| 252 | values, nevertheless (otherwise the use of an anonymous array |
| 253 | would be pointless). |
| 254 | .PP |
| 255 | Don't confuse year numbers and their substitutes (a date object |
| 256 | or an array reference) with Date::Calendar::Year objects, which |
| 257 | are a totally different thing! |
| 258 | .PP |
| 259 | But incidentally \f(CW\*(C`:\-)\*(C'\fR, you may also pass a Date::Calendar::Year |
| 260 | object whenever a year number is expected. However, and perhaps |
| 261 | against your expectations at times, only the year number from |
| 262 | that object will be used, not the year object itself (the year |
| 263 | object in question might be using the wrong profile!). |
| 264 | .PP |
| 265 | Moreover, whenever a method of this class returns a date, it |
| 266 | does so by returning a Date::Calc[::Object] date object. |
| 267 | .SH "IMPLEMENTATION" |
| 268 | .IX Header "IMPLEMENTATION" |
| 269 | Each Date::Calendar::Year object consists mainly of three bit |
| 270 | vectors, plus some administrative attributes, all stored in a |
| 271 | (blessed) hash. |
| 272 | .PP |
| 273 | All three bit vectors contain as many bits as there are days |
| 274 | in the corresponding year, i.e., either 365 or 366. |
| 275 | .PP |
| 276 | The first bit vector, called \*(L"\s-1FULL\s0\*(R", contains set bits for |
| 277 | Saturdays, Sundays and all \*(L"full\*(R" legal holidays (i.e., |
| 278 | days off, on which you usually do not work). |
| 279 | .PP |
| 280 | The second bit vector, called \*(L"\s-1HALF\s0\*(R", contains set bits for |
| 281 | all \*(L"half\*(R" holidays, i.e., holidays where you get only half |
| 282 | a day off from work. |
| 283 | .PP |
| 284 | The third and last bit vector, called \*(L"\s-1WORK\s0\*(R", is used as a |
| 285 | workspace, in which various calculations are performed |
| 286 | throughout this module. |
| 287 | .PP |
| 288 | Its name does \fB\s-1NOT\s0\fR come from \*(L"working days\*(R" (as you might |
| 289 | think), but from \*(L"workspace\*(R". |
| 290 | .PP |
| 291 | It only so happens that it is used to calculate the working |
| 292 | days sometimes, at some places in this module. |
| 293 | .PP |
| 294 | But you are free to use it yourself, for whatever calculation |
| 295 | you would like to carry out yourself. |
| 296 | .PP |
| 297 | The two other bit vectors, \*(L"\s-1FULL\s0\*(R" and \*(L"\s-1HALF\s0\*(R", should never be |
| 298 | changed, unless you know \fB\s-1EXACTLY\s0\fR what you're doing! |
| 299 | .SH "DESCRIPTION" |
| 300 | .IX Header "DESCRIPTION" |
| 301 | Functions |
| 302 | .IP "\(bu" 2 |
| 303 | \&\f(CW\*(C`check_year(YEAR);\*(C'\fR |
| 304 | .Sp |
| 305 | This function checks that the given year lies in the permitted |
| 306 | range [1583..2299]. It returns nothing in case of success, and |
| 307 | throws an exception (\*(L"given year out of range [1583..2299]\*(R") |
| 308 | otherwise. |
| 309 | .IP "\(bu" 2 |
| 310 | \&\f(CW\*(C`empty_period();\*(C'\fR |
| 311 | .Sp |
| 312 | This function issues a warning (from the perspective of the |
| 313 | caller of a Date::* module) that the given range of dates is |
| 314 | empty (\*(L"dates interval is empty\*(R"), provided that warnings are |
| 315 | enabled (i.e., "\f(CW$^W\fR" is true). |
| 316 | .Sp |
| 317 | This function is currently used by the method \*(L"\fIdelta_workdays()\fR\*(R" |
| 318 | in this class, and by its equivalent from the Date::Calendar |
| 319 | module. |
| 320 | .Sp |
| 321 | It is called whenever the range of dates of which the difference |
| 322 | in working days is to be calculated is empty. This can happen for |
| 323 | instance if you specify two adjacent dates both of which are not |
| 324 | to be included in the difference. |
| 325 | .PP |
| 326 | Methods |
| 327 | .IP "\(bu" 2 |
| 328 | \&\f(CW\*(C`$index = $year\->date2index(YEAR,MONTH,DAY|DATE);\*(C'\fR |
| 329 | .Sp |
| 330 | This method converts a given date into the number of the day in |
| 331 | that year (this is sometimes also referred to as the \*(L"julian\*(R" |
| 332 | date), i.e., a number between 0 (for January 1st) and the number |
| 333 | of days in the given year minus one, i.e., 364 or 365 (for |
| 334 | December 31st). |
| 335 | .Sp |
| 336 | You may need this in order to access the bit vectors returned |
| 337 | by the methods \*(L"\fIvec_full()\fR\*(R", \*(L"\fIvec_half()\fR\*(R" and \*(L"\fIvec_work()\fR\*(R". |
| 338 | .Sp |
| 339 | Note that there are shorthand methods in this module called |
| 340 | \&\*(L"\fIis_full()\fR\*(R", \*(L"\fIis_half()\fR\*(R" and \*(L"\fIis_work()\fR\*(R", which serve to test |
| 341 | individual bits of the three bit vectors which are a part of |
| 342 | each Date::Calendar::Year object. |
| 343 | .Sp |
| 344 | An exception (\*(L"given year != object's year\*(R") is thrown if the |
| 345 | year associated with the year object itself and the year from |
| 346 | the given date do not match. |
| 347 | .Sp |
| 348 | An exception (\*(L"invalid date\*(R") is also thrown if the given |
| 349 | arguments do not constitute a valid date, or (\*(L"given year |
| 350 | out of range [1583..2299]\*(R") if the given year lies outside |
| 351 | of the permitted range. |
| 352 | .IP "\(bu" 2 |
| 353 | \&\f(CW\*(C`$date = $year\->index2date(INDEX);\*(C'\fR |
| 354 | .Sp |
| 355 | This method converts an index (or \*(L"julian date\*(R") for the |
| 356 | given year back into a date. |
| 357 | .Sp |
| 358 | An exception (\*(L"invalid index\*(R") is thrown if the given index |
| 359 | is outside of the permitted range for the given year, i.e., |
| 360 | \&\f(CW\*(C`[0..364]\*(C'\fR or \f(CW\*(C`[0..365]\*(C'\fR. |
| 361 | .Sp |
| 362 | Note that this method returns a Date::Calc \fB\s-1OBJECT\s0\fR! |
| 363 | .IP "\(bu" 2 |
| 364 | \&\f(CW\*(C`$year_2000_US_FL = Date::Calendar::Year\->new( 2000, $Profiles\->{'US\-FL'} [,LANG] );\*(C'\fR |
| 365 | .Sp |
| 366 | \&\f(CW\*(C`$year_2001_DE_NW = Date::Calendar::Year\->new( 2001, $Profiles\->{'DE\-NW'} [,LANG] );\*(C'\fR |
| 367 | .Sp |
| 368 | \&\f(CW\*(C`$year = Date::Calendar::Year\->new( 2001, {} );\*(C'\fR |
| 369 | .Sp |
| 370 | This is the constructor method. Call it to create a new |
| 371 | Date::Calendar::Year object. |
| 372 | .Sp |
| 373 | The first argument must be a year number in the range |
| 374 | [1583..2299]. |
| 375 | .Sp |
| 376 | The second argument must be the reference of a hash, |
| 377 | which usually contains names of holidays and commemorative |
| 378 | days as keys and strings containing the date or formula |
| 379 | for each holiday as values. |
| 380 | .Sp |
| 381 | Reading this hash and initializing the object's internal |
| 382 | data is performed by an extra method, called \*(L"\fIinit()\fR\*(R", |
| 383 | which is called internally by the constructor method, |
| 384 | and which is described immediately below, after this |
| 385 | method. |
| 386 | .Sp |
| 387 | In case you call the \*(L"\fIinit()\fR\*(R" method yourself, explicitly, |
| 388 | after creating the object, you can pass an empty profile |
| 389 | (e.g., just an empty anonymous hash) to the \*(L"\fInew()\fR\*(R" method |
| 390 | in order to improve performance. |
| 391 | .Sp |
| 392 | The third argument is optional, and must consist of |
| 393 | the valid name or number of a language as provided by |
| 394 | the \fIDate::Calc\fR\|(3) module if given. |
| 395 | .Sp |
| 396 | This argument determines which language shall be used |
| 397 | when reading the profile, since the profile may contain |
| 398 | names of months and weekdays in its formulas in that |
| 399 | language. |
| 400 | .Sp |
| 401 | The default is English if none is specified. |
| 402 | .IP "\(bu" 2 |
| 403 | \&\f(CW\*(C`$year\->init( 2002, $Profiles\->{'DE\-SN'} [,LANG] );\*(C'\fR |
| 404 | .Sp |
| 405 | This method is called by the \*(L"\fInew()\fR\*(R" constructor method, |
| 406 | internally, and has the same arguments as the latter. |
| 407 | .Sp |
| 408 | See immediately above for a description of these arguments. |
| 409 | .Sp |
| 410 | Note that you can also call this method explicitly yourself, |
| 411 | if needed, and you can of course subclass the Date::Calendar::Year |
| 412 | class and override the \*(L"\fIinit()\fR\*(R" method with an method of your own. |
| 413 | .Sp |
| 414 | The holiday scheme or \*(L"profile\*(R" (i.e., the reference of |
| 415 | a hash passed as the second argument to this method) must |
| 416 | obey the following semantics and syntax: |
| 417 | .Sp |
| 418 | The keys are the names of the holiday or commemorative day |
| 419 | in question. Keys must be unique (but see further below). |
| 420 | .Sp |
| 421 | The difference between a holiday and a commemorative day is |
| 422 | that you (usually) get a day off on a holiday, whereas on a |
| 423 | purely commemorative day, you don't. |
| 424 | .Sp |
| 425 | A commemorative day is just a date with a name, nothing more. |
| 426 | .Sp |
| 427 | The values belonging to these keys can either be the code |
| 428 | reference of a callback function (see \fIDate::Calendar::Profiles\fR\|(3) |
| 429 | for more details and examples), or a string. |
| 430 | .Sp |
| 431 | All other values cause a fatal error with program abortion. |
| 432 | .Sp |
| 433 | The strings can specify three types of dates: |
| 434 | .Sp |
| 435 | .Vb 2 |
| 436 | \& - fixed dates |
| 437 | \& (like New Year, or first of January), |
| 438 | .Ve |
| 439 | .Sp |
| 440 | .Vb 2 |
| 441 | \& - dates relative to Easter Sunday |
| 442 | \& (like Ascension = Easter Sunday + 39 days), and |
| 443 | .Ve |
| 444 | .Sp |
| 445 | .Vb 3 |
| 446 | \& - the 1st, 2nd, 3rd, 4th or last |
| 447 | \& of a given day of week in a given month |
| 448 | \& (like "the 4th Thursday of November", or Thanksgiving). |
| 449 | .Ve |
| 450 | .Sp |
| 451 | All other types of dates must be specified via callback |
| 452 | functions. |
| 453 | .Sp |
| 454 | Note that the \*(L"last\*(R" of a given day of week is written as |
| 455 | the \*(L"5th\*(R", because the last is always either the 5th or the |
| 456 | 4th of the given day of week. So the \*(L"\fIinit()\fR\*(R" module first |
| 457 | calculates the 5th of the requested day of week, and if that |
| 458 | doesn't exist, takes the 4th instead. |
| 459 | .Sp |
| 460 | There are also two modifier characters which may prefix the |
| 461 | string with the date formula, \*(L"#\*(R" and \*(L":\*(R". |
| 462 | .Sp |
| 463 | The character \*(L"#\*(R" (mnemonic: it's only a comment) signals |
| 464 | that the date in question is a purely commemorative day, |
| 465 | i.e., it will not enter into any date calculations, but |
| 466 | can be queried with the \*(L"\fIlabels()\fR\*(R" and \*(L"\fIsearch()\fR\*(R" methods, |
| 467 | and appears when printing a calendar, for instance. |
| 468 | .Sp |
| 469 | The character \*(L":\*(R" (mnemonic: divided into two halfs) specifies |
| 470 | that the date in question is only a \*(L"half\*(R" holiday, i.e., you |
| 471 | only get half a day off instead of a full day. Some companies |
| 472 | have this sort of thing. \f(CW\*(C`:\-)\*(C'\fR |
| 473 | .Sp |
| 474 | The exact syntax for the date formula strings is the following |
| 475 | (by example): |
| 476 | .Sp |
| 477 | .Vb 1 |
| 478 | \& - Fixed dates: |
| 479 | .Ve |
| 480 | .Sp |
| 481 | .Vb 2 |
| 482 | \& "Christmas" => "24.12", # European format (day, month) |
| 483 | \& "Christmas" => "24.12.", |
| 484 | .Ve |
| 485 | .Sp |
| 486 | .Vb 4 |
| 487 | \& "Christmas" => "24Dec", |
| 488 | \& "Christmas" => "24.Dec", |
| 489 | \& "Christmas" => "24Dec.", |
| 490 | \& "Christmas" => "24.Dec.", |
| 491 | .Ve |
| 492 | .Sp |
| 493 | .Vb 2 |
| 494 | \& "Christmas" => "24-12", |
| 495 | \& "Christmas" => "24-12-", |
| 496 | .Ve |
| 497 | .Sp |
| 498 | .Vb 2 |
| 499 | \& "Christmas" => "24-Dec", |
| 500 | \& "Christmas" => "24-Dec-", |
| 501 | .Ve |
| 502 | .Sp |
| 503 | .Vb 3 |
| 504 | \& "Christmas" => "12/25", # American format (month, day) |
| 505 | \& "Christmas" => "Dec25", |
| 506 | \& "Christmas" => "Dec/25", |
| 507 | .Ve |
| 508 | .Sp |
| 509 | .Vb 1 |
| 510 | \& - Dates relative to Easter Sunday: |
| 511 | .Ve |
| 512 | .Sp |
| 513 | .Vb 13 |
| 514 | \& "Ladies' Carnival" => "-52", |
| 515 | \& "Carnival Monday" => "-48", |
| 516 | \& "Mardi Gras" => "-47", |
| 517 | \& "Ash Wednesday" => "-46", |
| 518 | \& "Palm Sunday" => "-7", |
| 519 | \& "Maundy Thursday" => "-3", |
| 520 | \& "Good Friday" => "-2", |
| 521 | \& "Easter Sunday" => "+0", |
| 522 | \& "Easter Monday" => "+1", |
| 523 | \& "Ascension" => "+39", |
| 524 | \& "Whitsunday" => "+49", |
| 525 | \& "Whitmonday" => "+50", |
| 526 | \& "Corpus Christi" => "+60", |
| 527 | .Ve |
| 528 | .Sp |
| 529 | .Vb 1 |
| 530 | \& - The 1st, 2nd, 3rd, 4th or last day of week: |
| 531 | .Ve |
| 532 | .Sp |
| 533 | .Vb 7 |
| 534 | \& "Thanksgiving" => "4Thu11", |
| 535 | \& "Thanksgiving" => "4/Thu/Nov", |
| 536 | \& "Columbus Day" => "2/Mon/Oct", |
| 537 | \& "Columbus Day" => "2/Mon/10", |
| 538 | \& "Columbus Day" => "2/1/Oct", |
| 539 | \& "Columbus Day" => "2/1/10", |
| 540 | \& "Memorial Day" => "5/Mon/May", # LAST Monday of May |
| 541 | .Ve |
| 542 | .Sp |
| 543 | Remember that each of these date formula strings may |
| 544 | also be prefixed with either \*(L"#\*(R" or \*(L":\*(R": |
| 545 | .Sp |
| 546 | .Vb 2 |
| 547 | \& "Christmas" => ":24.12.", # only half a day off |
| 548 | \& "Valentine's Day" => "#Feb/14", # not an official holiday |
| 549 | .Ve |
| 550 | .Sp |
| 551 | Note that the name of the month or day of week may have any |
| 552 | length you like, it just must specify the intended month or |
| 553 | day of week unambiguously. So \*(L"D\*(R", \*(L"De\*(R", \*(L"Dec\*(R", \*(L"Dece\*(R", |
| 554 | \&\*(L"Decem\*(R", \*(L"Decemb\*(R", \*(L"Decembe\*(R" and \*(L"December\*(R" would all |
| 555 | be valid, for example. Note also that case is ignored. |
| 556 | .Sp |
| 557 | When specifying day and month numbers, or offsets relative |
| 558 | to Easter Sunday, leading zeros are permitted (for nicely |
| 559 | indented formatting, for instance) but ignored. |
| 560 | .Sp |
| 561 | Leading zeros are not permitted in front of the ordinal |
| 562 | number [1..5] or the number of the day of week [1..7] |
| 563 | when specifying the nth day of week in a month. |
| 564 | .Sp |
| 565 | \&\fB\s-1BEWARE\s0\fR that if keys are not unique in the source code, |
| 566 | later entries will overwrite previous ones! I.e., |
| 567 | .Sp |
| 568 | .Vb 4 |
| 569 | \& ... |
| 570 | \& "My special holiday" => "01-11", |
| 571 | \& "My special holiday" => "02-11", |
| 572 | \& ... |
| 573 | .Ve |
| 574 | .Sp |
| 575 | will \fB\s-1NOT\s0\fR set two holidays of the same name, one on November |
| 576 | first, the other on November second, but only one, on November |
| 577 | second! |
| 578 | .Sp |
| 579 | Therefore, in order to use sets of defaults and to be able |
| 580 | to override some of them, you must \fB\s-1FIRST\s0\fR include any hash |
| 581 | containing the default definitions, and \fB\s-1THEN\s0\fR write down |
| 582 | your own definitions (see also the Date::Calendar::Profiles |
| 583 | module for examples of this!), like this: |
| 584 | .Sp |
| 585 | .Vb 6 |
| 586 | \& $defaults = |
| 587 | \& { |
| 588 | \& "Holiday #1" => "01-01", |
| 589 | \& "Holiday #2" => "02-02", |
| 590 | \& "Holiday #3" => "03-03" |
| 591 | \& }; |
| 592 | .Ve |
| 593 | .Sp |
| 594 | .Vb 6 |
| 595 | \& $variant1 = |
| 596 | \& { |
| 597 | \& %$defaults, |
| 598 | \& "Holiday #2" => "09-02", |
| 599 | \& "Holiday #4" => "04-04" |
| 600 | \& }; |
| 601 | .Ve |
| 602 | .Sp |
| 603 | This is because of the way hashes work in Perl. |
| 604 | .Sp |
| 605 | The \*(L"\fIinit()\fR\*(R" method proceeds as follows: |
| 606 | .Sp |
| 607 | First it checks whether the given year number lies in |
| 608 | the range [1583..2299]. A fatal error occurs if not. |
| 609 | .Sp |
| 610 | Then it determines the number of days in the requested |
| 611 | year, and stores it in the given Date::Calendar::Year |
| 612 | object. |
| 613 | .Sp |
| 614 | It then calls the \fIBit::Vector\fR\|(3) module to allocate three |
| 615 | bit vectors with a number of bits equal to the number of |
| 616 | days in the requested year, and stores the three object |
| 617 | references (of the bit vectors) in the Date::Calendar::Year |
| 618 | object. |
| 619 | .Sp |
| 620 | (See also the description of the three methods \*(L"\fIvec_full()\fR\*(R", |
| 621 | \&\*(L"\fIvec_half()\fR\*(R" and \*(L"\fIvec_full()\fR\*(R" immediately below.) |
| 622 | .Sp |
| 623 | It then sets the bits which correspond to Saturdays and |
| 624 | Sundays in the \*(L"full holidays\*(R" bit vector. |
| 625 | .Sp |
| 626 | At last, it iterates over the keys of the given holiday |
| 627 | scheme (of the hash referred to by the hash reference |
| 628 | passed to the \*(L"\fIinit()\fR\*(R" method as the second argument), |
| 629 | evaluates the formula (or calls the given callback |
| 630 | function), and sets the corresponding bit in the \*(L"full\*(R" |
| 631 | or \*(L"half\*(R" holidays bit vector if the calculated date |
| 632 | is valid. |
| 633 | .Sp |
| 634 | A fatal error occurs if the date formula cannot be parsed |
| 635 | or if the date returned by a formula or callback function |
| 636 | is invalid (e.g. 30\-Feb\-2001 or the like) or lies outside |
| 637 | the given year (e.g. Easter+365). |
| 638 | .Sp |
| 639 | Finally, the \*(L"\fIinit()\fR\*(R" method makes sure that days marked |
| 640 | as \*(L"full\*(R" holidays do not appear as \*(L"half\*(R" holidays as |
| 641 | well. |
| 642 | .Sp |
| 643 | Then the \*(L"\fIinit()\fR\*(R" method returns. |
| 644 | .Sp |
| 645 | Note that when deciphering the date formulas, the \*(L"\fIinit()\fR\*(R" |
| 646 | method uses the functions \*(L"\fIDecode_Day_of_Week()\fR\*(R" and |
| 647 | \&\*(L"\fIDecode_Month()\fR\*(R" from the \fIDate::Calc\fR\|(3) module, which |
| 648 | are language\-dependent. |
| 649 | .Sp |
| 650 | Therefore the \*(L"\fIinit()\fR\*(R" method allows you to pass it an optional |
| 651 | third argument, which must consist of the valid name or number |
| 652 | of a language as provided by the \fIDate::Calc\fR\|(3) module. |
| 653 | .Sp |
| 654 | For the time of scanning the given holiday scheme, the \*(L"\fIinit()\fR\*(R" |
| 655 | method will temporarily set the language to the value specified, |
| 656 | and it will restore the original value before returning. |
| 657 | .Sp |
| 658 | The default is English if none is specified. |
| 659 | .Sp |
| 660 | This means that you can provide the names of months and days of |
| 661 | week in your holiday profile in any of the languages supported |
| 662 | by the \fIDate::Calc\fR\|(3) module, provided you give the \*(L"\fIinit()\fR\*(R" |
| 663 | method a clue (the third parameter) which language to expect. |
| 664 | .IP "\(bu" 2 |
| 665 | \&\f(CW\*(C`$vector = $year\->vec_full();\*(C'\fR |
| 666 | .Sp |
| 667 | This method returns a reference to the bit vector in the |
| 668 | given year object which contains all \*(L"full\*(R" holidays. |
| 669 | .Sp |
| 670 | \&\fB\s-1BEWARE\s0\fR that you should \fB\s-1NEVER\s0\fR change the contents of this |
| 671 | bit vector unless you know \fB\s-1EXACTLY\s0\fR what you're doing! |
| 672 | .Sp |
| 673 | You should usually only read from this bit vector, or use it |
| 674 | as an operand in bit vector operations \- but never as an |
| 675 | lvalue. |
| 676 | .IP "\(bu" 2 |
| 677 | \&\f(CW\*(C`$vector = $year\->vec_half();\*(C'\fR |
| 678 | .Sp |
| 679 | This method returns a reference to the bit vector in the |
| 680 | given year object which contains all \*(L"half\*(R" holidays. |
| 681 | .Sp |
| 682 | \&\fB\s-1BEWARE\s0\fR that you should \fB\s-1NEVER\s0\fR change the contents of this |
| 683 | bit vector unless you know \fB\s-1EXACTLY\s0\fR what you're doing! |
| 684 | .Sp |
| 685 | You should usually only read from this bit vector, or use it |
| 686 | as an operand in bit vector operations \- but never as an |
| 687 | lvalue. |
| 688 | .IP "\(bu" 2 |
| 689 | \&\f(CW\*(C`$vector = $year\->vec_work();\*(C'\fR |
| 690 | .Sp |
| 691 | This method returns a reference to the \*(L"workspace\*(R" bit vector |
| 692 | in the given year object. |
| 693 | .Sp |
| 694 | Note that you cannot rely on the contents of this bit vector. |
| 695 | .Sp |
| 696 | You have to set it up yourself before performing any calculations |
| 697 | with it. |
| 698 | .Sp |
| 699 | Currently the contents of this bit vector are modified by the |
| 700 | two methods \*(L"\fIdelta_workdays()\fR\*(R" and \*(L"\fIadd_delta_workdays()\fR\*(R", in |
| 701 | ways which are hard to predict. |
| 702 | .Sp |
| 703 | The size of this bit vector can be determined through either |
| 704 | "\f(CW\*(C`$days = $vector\->Size();\*(C'\fR\*(L" or |
| 705 | \&\*(R"\f(CW\*(C`$days = $year\->val_days();\*(C'\fR". |
| 706 | .IP "\(bu" 2 |
| 707 | \&\f(CW\*(C`$size = $year\->val_days();\*(C'\fR |
| 708 | .Sp |
| 709 | This method returns the number of days in the given year object, |
| 710 | i.e., either 365 or 366. This is also the size (number of bits) |
| 711 | of the three bit vectors contained in the given year object. |
| 712 | .IP "\(bu" 2 |
| 713 | \&\f(CW\*(C`$base = $year\->val_base();\*(C'\fR |
| 714 | .Sp |
| 715 | This method returns the value of the expression |
| 716 | "\f(CW\*(C`Date_to_Days($year\->val_year(),1,1)\*(C'\fR", or in other words, |
| 717 | the number of days between January 1st of the year 1 and January |
| 718 | 1st of the given year, plus one. |
| 719 | .Sp |
| 720 | This value is used internally by the method \*(L"\fIdate2index()\fR\*(R" in order |
| 721 | to calculate the \*(L"julian\*(R" date or day of the year for a given date. |
| 722 | .Sp |
| 723 | The expression above is computed only once in method \*(L"\fIinit()\fR\*(R" and |
| 724 | then stored in one of the year object's attributes, of which this |
| 725 | method just returns the value. |
| 726 | .IP "\(bu" 2 |
| 727 | \&\f(CW\*(C`$number = $year\->val_year();\*(C'\fR |
| 728 | .Sp |
| 729 | \&\f(CW\*(C`$number = $year\->year();\*(C'\fR |
| 730 | .Sp |
| 731 | These two methods are identical, the latter being a shortcut of |
| 732 | the former. |
| 733 | .Sp |
| 734 | They return the number of the year for which a calendar has been |
| 735 | stored in the given year object. |
| 736 | .Sp |
| 737 | The method name \*(L"\fIval_year()\fR\*(R" is used here in order to be consistent |
| 738 | with the other attribute accessor methods of this class, and the |
| 739 | method \*(L"\fIyear()\fR\*(R" is necessary in order to be able to pass |
| 740 | Date::Calendar::Year objects as parameters instead of a year number |
| 741 | in the methods of the Date::Calendar and Date::Calendar::Year |
| 742 | modules. |
| 743 | .IP "\(bu" 2 |
| 744 | \&\f(CW\*(C`@names = $year\->labels(YEAR,MONTH,DAY|DATE);\*(C'\fR |
| 745 | .Sp |
| 746 | \&\f(CW\*(C`@holidays = $year\->labels();\*(C'\fR |
| 747 | .Sp |
| 748 | \&\f(CW\*(C`$holidays = $year\->labels();\*(C'\fR |
| 749 | .Sp |
| 750 | If any arguments are given, they are supposed to represent a |
| 751 | date. In that case, a list of all labels (= names of holidays) |
| 752 | associated with that date are returned. The first item returned |
| 753 | is always the name of the day of week for that date. |
| 754 | .Sp |
| 755 | If no arguments are given, the list of all available labels in |
| 756 | the given year is returned. This list does \fB\s-1NOT\s0\fR include any |
| 757 | names of the days of week (which would be pointless in this case). |
| 758 | .Sp |
| 759 | In list context, the resulting list itself is returned. In scalar |
| 760 | context, the number of items in the resulting list is returned. |
| 761 | .IP "\(bu" 2 |
| 762 | \&\f(CW\*(C`@dates = $year\->search(PATTERN);\*(C'\fR |
| 763 | .Sp |
| 764 | \&\f(CW\*(C`$dates = $year\->search(PATTERN);\*(C'\fR |
| 765 | .Sp |
| 766 | This method searches through all the labels of the given year |
| 767 | and returns a list of date objects with all dates whose labels |
| 768 | match the given pattern. |
| 769 | .Sp |
| 770 | Note that this is a simple, case-insensitive substring search, |
| 771 | \&\fB\s-1NOT\s0\fR a full-fledged regular expression search! |
| 772 | .Sp |
| 773 | The result is guaranteed to be sorted chronologically. |
| 774 | .Sp |
| 775 | In scalar context, only the number of items in the resulting list |
| 776 | is returned, instead of the resulting list itself (as in list context). |
| 777 | .IP "\(bu" 2 |
| 778 | \&\f(CW\*(C`$days = $year\->delta_workdays(YEAR,MONTH1,DAY1, YEAR,MONTH2,DAY2, FLAG1,FLAG2);\*(C'\fR |
| 779 | .Sp |
| 780 | \&\f(CW\*(C`$days = $year\->delta_workdays(DATE1,DATE2,FLAG1,FLAG2);\*(C'\fR |
| 781 | .Sp |
| 782 | This method calculates the number of work days (i.e., the number |
| 783 | of days, but excluding all holidays) between two dates. |
| 784 | .Sp |
| 785 | In other words, this method is equivalent to the \*(L"\fIDelta_Days()\fR\*(R" |
| 786 | function of the Date::Calc module, except that it disregards |
| 787 | holidays in its counting. |
| 788 | .Sp |
| 789 | The two flags indicate whether the start and end dates should be |
| 790 | included in the counting (that is, of course, only in case they |
| 791 | aren't holidays), or not. |
| 792 | .Sp |
| 793 | It is common, for example, that you want to know how many work |
| 794 | days are left between the current date and a given deadline. |
| 795 | .Sp |
| 796 | Typically, you will want to count the current date but not the |
| 797 | deadline's date. So you would specify \*(L"true\*(R" (\*(L"1\*(R") for \s-1FLAG1\s0 |
| 798 | and \*(L"false\*(R" (\*(L"0\*(R") for \s-1FLAG2\s0 in order to achieve that. |
| 799 | .Sp |
| 800 | In other words, a value of \*(L"true\*(R" means \*(L"including this date\*(R", |
| 801 | a value of \*(L"false\*(R" means \*(L"excluding this date\*(R". |
| 802 | .Sp |
| 803 | As with the \*(L"\fIDelta_Days()\fR\*(R" function from the Date::Calc module, |
| 804 | the dates have to be given in chronological order to yield a |
| 805 | positive result. If the dates are reversed, the result will |
| 806 | be negative. |
| 807 | .Sp |
| 808 | The parameter \s-1FLAG1\s0 is associated with the first given date, |
| 809 | the parameter \s-1FLAG2\s0 with the second given date (regardless |
| 810 | of whether the dates are in chronological order or not). |
| 811 | .Sp |
| 812 | An exception (\*(L"given year != object's year\*(R") is thrown if the |
| 813 | year number of either of the two given dates does not match the |
| 814 | year number associated with the given year object. |
| 815 | .Sp |
| 816 | An exception (\*(L"invalid date\*(R") is also raised if either of the |
| 817 | two date arguments does not constitute a valid date. |
| 818 | .IP "\(bu" 2 |
| 819 | \&\f(CW\*(C`($date,$rest,$sign) = $year\->add_delta_workdays(YEAR,MONTH,DAY, DELTA, SIGN);\*(C'\fR |
| 820 | .Sp |
| 821 | \&\f(CW\*(C`($date,$rest,$sign) = $year\->add_delta_workdays(DATE,DELTA,SIGN);\*(C'\fR |
| 822 | .Sp |
| 823 | This method is the equivalent of the \*(L"\fIAdd_Delta_Days()\fR\*(R" function |
| 824 | from the Date::Calc module, except that it adds work days and |
| 825 | skips holidays. |
| 826 | .Sp |
| 827 | In other words, you can add or subtract a number of work days |
| 828 | \&\*(L"\s-1DELTA\s0\*(R" to/from a given date and get a new date as the result |
| 829 | (as a Date::Calc object). |
| 830 | .Sp |
| 831 | You add days (i.e., you go forward in time) with a positive |
| 832 | offset \*(L"\s-1DELTA\s0\*(R", and you subtract days (i.e., you go backwards |
| 833 | in time) with a negative offset. |
| 834 | .Sp |
| 835 | Note that an exception (\*(L"invalid date\*(R") is raised if the |
| 836 | given date argument (the \*(L"start\*(R" date) does not constitute |
| 837 | a valid date. |
| 838 | .Sp |
| 839 | Beware that this method is limited to date calculations within |
| 840 | a single year (in contrast to the method with the same name |
| 841 | from the Date::Calendar module). |
| 842 | .Sp |
| 843 | Therefore, the method does not only return a date (object), |
| 844 | but also a \*(L"rest\*(R" and a \*(L"sign\*(R". |
| 845 | .Sp |
| 846 | The \*(L"rest\*(R" indicates how many days are still left from your |
| 847 | original \s-1DELTA\s0 after going in the desired direction and |
| 848 | reaching a year boundary. |
| 849 | .Sp |
| 850 | The \*(L"sign\*(R" indicates in which direction (future or past) one |
| 851 | needs to go in order to \*(L"eat up\*(R" the \*(L"rest\*(R" (by subtracting |
| 852 | a day from the \*(L"rest\*(R" for each work day passed), or to adjust |
| 853 | the resulting date (in order to skip any holidays directly |
| 854 | after a year boundary), if at all. |
| 855 | .Sp |
| 856 | The \*(L"sign\*(R" is \-1 for going backwards in time, +1 for going |
| 857 | forward, and 0 if the result doesn't need any more fixing |
| 858 | (for instance because the result lies in the same year as |
| 859 | the starting date). |
| 860 | .Sp |
| 861 | The method \*(L"\fIadd_delta_workdays()\fR\*(R" from the Date::Calendar |
| 862 | module uses the \*(L"rest\*(R" and \*(L"sign\*(R" return values from this |
| 863 | method in order to perform calculations which may cross |
| 864 | year boundaries. |
| 865 | .Sp |
| 866 | Therefore, it is not recommended to use this method here |
| 867 | directly, as it is rather clumsy to use, but to use the |
| 868 | method with the same name from the Date::Calendar module |
| 869 | instead, which does the same but is much easier to use |
| 870 | and moreover allows calculations which cross an arbitrary |
| 871 | number of year boundaries. |
| 872 | .IP "\(bu" 2 |
| 873 | \&\f(CW\*(C`$flag = $year\->is_full(YEAR,MONTH,DAY|DATE);\*(C'\fR |
| 874 | .Sp |
| 875 | This method returns \*(L"true\*(R" (\*(L"1\*(R") if the bit corresponding to |
| 876 | the given date is set in the bit vector representing \*(L"full\*(R" |
| 877 | holidays, and \*(L"false\*(R" (\*(L"0\*(R") otherwise. |
| 878 | .Sp |
| 879 | I.e., the method returns \*(L"true\*(R" if the given date is a (full) |
| 880 | holiday (according to the calendar profile associated with the |
| 881 | given year object). |
| 882 | .IP "\(bu" 2 |
| 883 | \&\f(CW\*(C`$flag = $year\->is_half(YEAR,MONTH,DAY|DATE);\*(C'\fR |
| 884 | .Sp |
| 885 | This method returns \*(L"true\*(R" (\*(L"1\*(R") if the bit corresponding to |
| 886 | the given date is set in the bit vector representing \*(L"half\*(R" |
| 887 | holidays, and \*(L"false\*(R" (\*(L"0\*(R") otherwise. |
| 888 | .Sp |
| 889 | I.e., the method returns \*(L"true\*(R" if the given date is a half |
| 890 | holiday (according to the calendar profile associated with the |
| 891 | given year object). |
| 892 | .Sp |
| 893 | Note that if a date is a \*(L"full\*(R" holiday, the \*(L"half\*(R" bit is |
| 894 | never set, even if you try to do so in your calendar profile, |
| 895 | on purpose or by accident. |
| 896 | .IP "\(bu" 2 |
| 897 | \&\f(CW\*(C`$flag = $year\->is_work(YEAR,MONTH,DAY|DATE);\*(C'\fR |
| 898 | .Sp |
| 899 | This method returns \*(L"true\*(R" (\*(L"1\*(R") if the bit corresponding to |
| 900 | the given date is set in the bit vector used to perform all |
| 901 | sorts of calculations, and \*(L"false\*(R" (\*(L"0\*(R") otherwise. |
| 902 | .Sp |
| 903 | \&\fB\s-1BEWARE\s0\fR that the \*(L"work\*(R" in this method's name does \fB\s-1NOT\s0\fR |
| 904 | come from \*(L"work days\*(R"! |
| 905 | .Sp |
| 906 | It comes from the fact that the corresponding bit vector can |
| 907 | be used for any \*(L"work\*(R" that you need to do. In other words, |
| 908 | it's a \*(L"work space\*(R". |
| 909 | .Sp |
| 910 | Therefore, this bit vector might contain about everything you |
| 911 | could imagine \- including a bit pattern which marks all \*(L"work |
| 912 | days\*(R" with set bits, if it so happens! |
| 913 | .Sp |
| 914 | But you better don't rely on it, unless you put the bit pattern |
| 915 | there yourself in the first place. |
| 916 | .Sp |
| 917 | Note that you can get a reference to this bit vector (in order |
| 918 | to fill it with any bit pattern you like) using the method |
| 919 | \&\*(L"\fIvec_work()\fR\*(R", described further above in this document. |
| 920 | .Sp |
| 921 | The number of bits in this bit vector is the same as the number |
| 922 | of days in the given year "\f(CW$year\fR\*(L", which you can retrieve |
| 923 | through either \*(R"\f(CW\*(C`$days = $year\->vec_work\->Size();\*(C'\fR\*(L" |
| 924 | or \*(R"\f(CW\*(C`$days = $year\->val_days();\*(C'\fR". |
| 925 | .Sp |
| 926 | See also \fIBit::Vector\fR\|(3) for more details. |
| 927 | .SH "SEE ALSO" |
| 928 | .IX Header "SEE ALSO" |
| 929 | \&\fIBit::Vector\fR\|(3), \fIDate::Calendar\fR\|(3), \fIDate::Calendar::Profiles\fR\|(3), |
| 930 | \&\fIDate::Calc::Object\fR\|(3), \fIDate::Calc\fR\|(3). |
| 931 | .SH "VERSION" |
| 932 | .IX Header "VERSION" |
| 933 | This man page documents \*(L"Date::Calendar::Year\*(R" version 5.3. |
| 934 | .SH "AUTHOR" |
| 935 | .IX Header "AUTHOR" |
| 936 | .Vb 3 |
| 937 | \& Steffen Beyer |
| 938 | \& mailto:sb@engelschall.com |
| 939 | \& http://www.engelschall.com/u/sb/download/ |
| 940 | .Ve |
| 941 | .SH "COPYRIGHT" |
| 942 | .IX Header "COPYRIGHT" |
| 943 | Copyright (c) 2000 \- 2002 by Steffen Beyer. All rights reserved. |
| 944 | .SH "LICENSE" |
| 945 | .IX Header "LICENSE" |
| 946 | This package is free software; you can redistribute it and/or |
| 947 | modify it under the same terms as Perl itself, i.e., under the |
| 948 | terms of the \*(L"Artistic License\*(R" or the \*(L"\s-1GNU\s0 General Public License\*(R". |
| 949 | .PP |
| 950 | Please refer to the files \*(L"Artistic.txt\*(R" and \*(L"\s-1GNU_GPL\s0.txt\*(R" |
| 951 | in this distribution for details! |
| 952 | .SH "DISCLAIMER" |
| 953 | .IX Header "DISCLAIMER" |
| 954 | This package is distributed in the hope that it will be useful, |
| 955 | but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of |
| 956 | \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. |
| 957 | .PP |
| 958 | See the \*(L"\s-1GNU\s0 General Public License\*(R" for more details. |