1Date::Manip(3) User Contributed Perl Documentation Date::Manip(3)
2
3
4
6 Date::Manip - Date manipulation routines
7
9 Date::Manip is a series of modules which can do pretty much any
10 date/time operation you could ever want.
11
12 As of 6.00, there are two ways to use Date::Manip.
13
14 Functional
15 Prior to 6.00, Date::Manip had only a functional interface.
16 Existing scripts which used older versions of Date::Manip will
17 continue to work (though you should check out the
18 Date::Manip::Migration5to6 document for a list of changes which may
19 be necessary).
20
21 Object-Oriented
22 As of 6.00, Date::Manip consists of a set of OO modules. Each have
23 their own document (see the SEE ALSO section below). The functional
24 interface is now just a wrapper around these OO modules.
25
26 The OO interface consists of the following modules:
27 Date::Manip::Date, Date::Manip::Delta, Date::Manip::Recur,
28 Date::Manip::TZ, and Date::Manip::Base
29
30 All Date::Manip operations can be performed using the OO modules.
31 Most of the common operations can also be done using the functional
32 interface, but there are some limitations.
33
34 The biggest limitation is that the functional interface has limited
35 time zone handling (though what it has is now correct). For full
36 time zone handling, you need to use the OO modules.
37
38 Which interface should you use?
39
40 If you need full time zone support, you need to use the OO interface
41 since the functional interface is limited in it's ability to handle
42 time zones correctly.
43
44 If you want to write a script that will work with older versions of
45 Date::Manip, you need to use the functional interface (but be aware
46 that not all config variables in 6.00 are available in 5.xx).
47
48 For new scripts, it is suggested that the OO interface be used.
49
51 use Date::Manip;
52
53 $version = DateManipVersion($flag);
54
55 Date_Init("VAR=VAL","VAR=VAL",...);
56
57 $date = ParseDate(\@args);
58 $date = ParseDate($string);
59 $date = ParseDate(\$string);
60
61 $date = ParseDateString($string);
62
63 @date = UnixDate($date,@format);
64 $date = UnixDate($date,@format);
65
66 $delta = ParseDateDelta(\@args);
67 $delta = ParseDateDelta($string);
68 $delta = ParseDateDelta(\$string);
69
70 @str = Delta_Format($delta,$dec,@format);
71 $str = Delta_Format($delta,$dec,@format);
72
73 $recur = ParseRecur($string,$base,$date0,$date1,$flags);
74 @dates = ParseRecur($string,$base,$date0,$date1,$flags);
75
76 $flag = Date_Cmp($date1,$date2);
77
78 $d = DateCalc($d1,$d2 [,$errref] [,$mode]);
79
80 $date = Date_SetTime($date,$hr,$min,$sec);
81 $date = Date_SetTime($date,$time);
82
83 $date = Date_SetDateField($date,$field,$val [,$nocheck]);
84
85 $date = Date_GetPrev($date,$dow,$today,$hr,$min,$sec);
86 $date = Date_GetPrev($date,$dow,$today,$time);
87
88 $date = Date_GetNext($date,$dow,$today,$hr,$min,$sec);
89 $date = Date_GetNext($date,$dow,$today,$time);
90
91 $name = Date_IsHoliday($date);
92
93 $listref = Events_List($date);
94 $listref = Events_List($date0,$date1);
95
96 $date = Date_ConvTZ($date,$from,$to);
97
98 $flag = Date_IsWorkDay($date [,$flag]);
99
100 $date = Date_NextWorkDay($date,$off [,$time]);
101
102 $date = Date_PrevWorkDay($date,$off [,$time]);
103
104 $date = Date_NearestWorkDay($date [,$tomorrowfirst]);
105
106 In the following routines, $y may be entered as either a 2 or 4 digit
107 year (it will be converted to a 4 digit year based on the variable
108 YYtoYYYY described below). Month and day should be numeric in all
109 cases.
110
111 $day = Date_DayOfWeek($m,$d,$y);
112 $secs = Date_SecsSince1970($m,$d,$y,$h,$mn,$s);
113 $secs = Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s);
114 $days = Date_DaysSince1BC($m,$d,$y);
115 $day = Date_DayOfYear($m,$d,$y);
116 ($y,$m,$d,$h,$mn,$s) = Date_NthDayOfYear($y,$n);
117 $days = Date_DaysInYear($y);
118 $days = Date_DaysInMonth($m,$y);
119 $wkno = Date_WeekOfYear($m,$d,$y,$first);
120 $flag = Date_LeapYear($y);
121 $day = Date_DaySuffix($d);
122 $tz = Date_TimeZone();
123
125 Date::Manip is a series of modules designed to make any common
126 date/time manipulation easy to do. Operations such as comparing two
127 times, calculating a time a given amount of time from another, or
128 parsing international times are all easily done. From the very
129 beginning, the main focus of Date::Manip has been to be able to do ANY
130 desired date/time operation easily, not necessarily quickly. Also, it
131 is definitely oriented towards the type of operations we (as people)
132 tend to think of rather than those operations used routinely by
133 computers. There are other modules that can do a subset of the
134 operations available in Date::Manip much quicker than those presented
135 here, so be sure to read the section SHOULD I USE DATE::MANIP in the
136 Date::Manip::Misc document before deciding which of the Date and Time
137 modules from CPAN is for you.
138
139 Date::Manip deals with time as it is used in the Gregorian calendar
140 (the one currently in use) with full support for time changes due to
141 daylight saving time.
142
143 Date::Manip has functionality to work with several fundamental types of
144 data.
145
146 dates
147 A date consists of three pieces of information: a calendar date, a
148 time of day, and time zone information. All are fully handled.
149
150 delta
151 A delta is an amount of time (i.e. the amount of time between two
152 different dates).
153
154 recurrence
155 A recurring event is something which occurs on a regular recurring
156 basis.
157
158 Among other things, Date::Manip allow you to:
159
160 · Enter a date in practically any format you choose.
161
162 · Compare two dates, entered in widely different formats to determine
163 which is earlier.
164
165 · Extract any information you want from a date using a format string
166 similar to the Unix date command.
167
168 · Determine the amount of time between two dates, or add an amount of
169 time to a date to get a second date.
170
171 · Work with dates with dates using international formats (foreign
172 month names, 12/10/95 referring to October rather than December,
173 etc.).
174
175 · To find a list of dates where a recurring event happens.
176
177 Each of these tasks is trivial (one or two lines at most) with this
178 package.
179
181 DateManipVersion
182 $version = DateManipVersion($flag);
183
184 Returns the version of Date::Manip. If $flag is non-zero, timezone
185 information is also returned.
186
187 Date_Init
188 Date_Init("VAR=VAL","VAR=VAL",...);
189
190 The Date_Init function is used to set any of the Date::Manip
191 configuration variables described in the Date::Manip::Config
192 document.
193
194 The strings to pass in are of the form "VAR=VAL". Any number may
195 be included and they can come in any order. VAR may be any
196 configuration variable. VAL is any allowed value for that
197 variable. For example, to switch from English to French and use
198 non-US format (so that 12/10 is Oct 12), do the following:
199
200 Date_Init("Language=French","DateFormat=non-US");
201
202 Note that variables are parsed in the order they are given, so
203 "DateFormat=non-US", "ConfigFile=./manip.cnf" may not give the
204 expected result. To be safe, ConfigFile should always appear first
205 in the list.
206
207 ParseDate
208 $date = ParseDate(\@args);
209 $date = ParseDate($string);
210 $date = ParseDate(\$string);
211
212 This takes an array or a string containing a date and parses it.
213 When the date is included as an array (for example, the arguments
214 to a program) the array should contain a valid date in the first
215 one or more elements (elements after a valid date are ignored).
216 Elements containing a valid date are shifted from the array. The
217 largest possible number of elements which can be correctly
218 interpreted as a valid date are always used. If a string is
219 entered rather than an array, that string is tested for a valid
220 date. The string is unmodified, even if passed in by reference.
221
222 The ParseDate routine is primarily used to handle command line
223 arguments. If you have a command where you want to enter a date as
224 a command line argument, you can use Date::Manip to make something
225 like the following work:
226
227 mycommand -date Dec 10 1997 -arg -arg2
228
229 No more reading man pages to find out what date format is required
230 in a man page.
231
232 Historical note: this is originally why the Date::Manip routines
233 were written (though long before they were released as the
234 Date::Manip module). I was using a bunch of programs (primarily
235 batch queue managers) where dates and times were entered as command
236 line options and I was getting highly annoyed at the many different
237 (but not compatible) ways that they had to be entered. Date::Manip
238 originally consisted of basically 1 routine which I could pass
239 "@ARGV" to and have it remove a date from the beginning.
240
241 ParseDateString
242 $date = ParseDateString($string);
243
244 This parses a string containing a date and returns it. Refer to the
245 Date::Manip::Date documentation for valid date formats. The date
246 returned is in the local time zone.
247
248 UnixDate
249 $out = UnixDate($date,$in);
250 @out = UnixDate($date,@in);
251
252 This takes a date and a list of strings containing formats roughly
253 identical to the format strings used by the UNIX date(1) command.
254 Each format is parsed and an array of strings corresponding to each
255 format is returned.
256
257 The formats are described in the Date::Manip::Date document.
258
259 ParseDateDelta
260 $delta = ParseDateDelta(\@args);
261 $delta = ParseDateDelta($string);
262 $delta = ParseDateDelta(\$string);
263
264 In the first form, it takes an array and shifts a valid delta from
265 it. In the other two forms, it parses a string to see if it
266 contains a valid delta.
267
268 A valid delta is returned if found. Otherwise, an empty string is
269 returned.
270
271 Delta_Format
272 $out = Delta_Format($delta [,$mode], $dec,$in);
273 @out = Delta_Format($delta [,$mode], $dec,@in);
274
275 This is similar to the UnixDate routine except that it extracts
276 information from a delta.
277
278 When formatting fields in a delta, the Date::Manip 6.00 formats
279 have changed and are much more powerful. The old 5.xx formats are
280 still available for the Delta_Format command for backward
281 compatibility. These formats include:
282
283 %Xv : print the value of the field X
284
285 %Xd : print the value of the field X and all
286 smaller units in terms of X
287
288 %Xh : print the value of field X and all
289 larger units in terms of X
290
291 %Xt : print the value of all fields in
292 terms of X
293
294 These make use of the $mode and $dec arguments to determine how to
295 format the information.
296
297 $dec is an integer, and is required, It tells the number of decimal
298 places to use.
299
300 $mode is either "exact" or "approx" and defaults to "exact" if it
301 is not included.
302
303 In "exact" mode, only exact relationships are used. This means
304 that there can be no mixing of the Y/M and W/D/H/MN/S segments (for
305 non-business deltas, or Y/M, W, and D/H/MN/S segments for business
306 deltas) because there is no exact relation between the fields of
307 each set.
308
309 In "approx" mode, approximate relationships are used. These are
310 described in the Date::Manip::Delta manual.
311
312 So, in "exact" mode, with a non-business delta, and $dec = 2, the
313 following are equivalent:
314
315 old style new style
316 --------- ---------
317 %Xv %Xv
318 %hd %.2hhs
319 %hh %.2hdh
320 %ht %.2hds
321 %yd %.2yyM
322
323 In "approximate" mode, the following are equivalent:
324
325 old style new style
326 --------- ---------
327 %Xv %Xv
328 %hd %.2hhs
329 %hh %.2hdh
330 %ht %.2hys
331 %yd %.2yys
332
333 If you want to use the new style formats in Delta_Format, use one
334 of the calls:
335
336 Delta_Format($delta, @in);
337 Delta_Format($delta, undef, @in);
338
339 If the first element of @in is an integer, you have to use the 2nd
340 form.
341
342 The old formats will remain available for the time being, though at
343 some point they may be deprecated.
344
345 DateCalc
346 $d = DateCalc($d1,$d2 [,\$err] [,$mode]);
347
348 This takes two dates, deltas, or one of each and performs the
349 appropriate calculation with them. Dates must be a string that can
350 be parsed by ParseDateString. Deltas must be a string that can be
351 parsed by ParseDateDelta. Two deltas add together to form a third
352 delta. A date and a delta returns a 2nd date. Two dates return a
353 delta (the difference between the two dates).
354
355 Since the two items can be interpreted as either dates or deltas,
356 and since many strings can be interpreted as both a date or a
357 delta, it is a good idea to pass the input through ParseDateDelta,
358 if appropriate if there is any ambiguity. For example, the string
359 "09:00:00" can be interpreted either as a date (today at 9:00:00)
360 or a delta (9 hours). To avoid unexpected results, avoid calling
361 DateCalc as:
362
363 $d = DateCalc("09:00:00",$someothervalue);
364
365 Instead, call it as:
366
367 $d = DateCalc(ParseDate("09:00:00"),$someothervalue);
368
369 to force it to be a date, or:
370
371 $d = DateCalc(ParseDateDelta("09:00:00"),$someothervalue);
372
373 to force it to be a delta. This will avoid unexpected results.
374 Passing something through ParseDate is optional since they will be
375 treated as dates by default (and for performance reasons, you're
376 better off not calling ParseDate).
377
378 If there is no ambiguity, you are better off NOT doing this for
379 performance reasons. If the delta is a business delta, you
380 definitely should NOT do this.
381
382 One other thing to note is that when parsing dates, a delta can be
383 interpreted as a date relative to now. DateCalc will ALWAYS treat a
384 delta as a delta, NOT a date.
385
386 For details on how calculations are done, refer to the
387 Date::Manip::Calc documentation.
388
389 By default, math is done using an exact mode.
390
391 If two deltas, or a date and a delta are passed in, $mode may be
392 used to force the delta to be either business or non-business mode
393 deltas. If $mode is 0 or 1, the delta(s) will be non-business.
394 Otherwise, they will be business deltas. If $mode is passed in, it
395 will be used only if the business or non-business state was not
396 explicitly set in the delta.
397
398 If two dates are passed in, $mode is used to determine the type of
399 calculation. By default, an exact delta is produced. If $mode is
400 1, an approximate delta is produced. If $mode is 2, a business
401 approximate (bapprox) mode calculation is done. If $mode is 3, a
402 exact business mode delta is produced.
403
404 If \$err is passed in, it is set to:
405 1 is returned if $d1 is not a delta or date
406 2 is returned if $d2 is not a delta or date
407 3 if any other error occurs. This argument is optional, but if
408 included, it must come before $mode.
409
410 Nothing is returned if an error occurs.
411
412 ParseRecur
413 $recur = ParseRecur($string [,$base,$date0,$date1,$flags]);
414 @dates = ParseRecur($string [,$base,$date0,$date1,$flags]);
415
416 This parses a string containing a recurrence and returns a fully
417 specified recurrence, or a list of dates referred to.
418
419 $string can be any of the forms:
420
421 FREQ
422 FREQ*FLAGS
423 FREQ*FLAGS*BASE
424 FREQ*FLAGS*BASE*DATE0
425 FREQ*FLAGS*BASE*DATE0*DATE1
426
427 where FREQ is a frequence (see the Date::Manip::Delta
428 documentation), FLAGS is a comma separated list of flags, and BASE,
429 DATE0, and DATE1 are date strings. The dates and flags can also be
430 passed in as $base, $date0, $date1, and $flags, and these will
431 override any values in $string.
432
433 In scalar context, the fully specified recurrence (or as much
434 information as is available) will be returned. In list context, a
435 list of dates will be returned.
436
437 Date_Cmp
438 $flag = Date_Cmp($date1,$date2);
439
440 This takes two dates and compares them. Any dates that can be
441 parsed will be compared.
442
443 Date_GetPrev
444 $date = Date_GetPrev($date,$dow, $curr [,$hr,$min,$sec]);
445 $date = Date_GetPrev($date,$dow, $curr [,$time]);
446 $date = Date_GetPrev($date,undef,$curr,$hr,$min,$sec);
447 $date = Date_GetPrev($date,undef,$curr,$time);
448
449 This takes a date (any string that may be parsed by
450 ParseDateString) and finds the previous occurrence of either a day
451 of the week, or a certain time of day.
452
453 This is documented in the "prev" method in Date::Manip::Date,
454 except that here, $time is a string (HH, HH:MN:, or HH:MN:SS), and
455 $dow may be a string of the form "Fri" or "Friday".
456
457 Date_GetNext
458 $date = Date_GetNext($date,$dow, $curr [,$hr,$min,$sec]);
459 $date = Date_GetNext($date,$dow, $curr [,$time]);
460 $date = Date_GetNext($date,undef,$curr,$hr,$min,$sec);
461 $date = Date_GetNext($date,undef,$curr,$time);
462
463 Similar to Date_GetPrev.
464
465 Date_SetTime
466 $date = Date_SetTime($date,$hr,$min,$sec);
467 $date = Date_SetTime($date,$time);
468
469 This takes a date (any string that may be parsed by
470 ParseDateString) and sets the time in that date. For example, one
471 way to get the time for 7:30 tomorrow would be to use the lines:
472
473 $date = ParseDate("tomorrow");
474 $date = Date_SetTime($date,"7:30");
475
476 $time is a string (HH, HH:MN, or HH:MN:SS).
477
478 Date_SetDateField
479 $date = Date_SetDateField($date,$field,$val);
480
481 This takes a date and sets one of its fields to a new value.
482 $field is any of the strings "y", "m", "d", "h", "mn", "s" (case
483 insensitive) and $val is the new value.
484
485 Date_IsHoliday
486 $name = Date_IsHoliday($date);
487
488 This returns undef if $date is not a holiday, or a string
489 containing the name of the holiday otherwise. An empty string is
490 returned for an unnamed holiday.
491
492 Date_IsWorkDay
493 $flag = Date_IsWorkDay($date [,$flag]);
494
495 This returns 1 if $date is a work day. If $flag is non-zero, the
496 time is checked to see if it falls within work hours. It returns
497 an empty string if $date is not valid.
498
499 Events_List
500 $ref = Events_List($date);
501 $ref = Events_List($date,0 [,$flag]);
502 $ref = Events_List($date,$date1 [,$flag]);
503
504 This returns a list of events. If $flag is not given, or is equal
505 to 0, the list (returned as a reference) is similar to the the list
506 returned by the Date::Manip::Date::list_events method with $format
507 = "dates". The only difference is that it is formatted slightly
508 different to be backward compatible with Date::Manip 5.xx.
509
510 The data from the list_events method is:
511
512 ( [DATE1, NAME1a, NAME1b, ...],
513 [DATE2, NAME2a, NAME2b, ...],
514 ...
515 )
516
517 The reference returned from Events_List (if $flag = 0) is:
518
519 [ DATE1, [NAME1a, NAME1b, ...],
520 DATE2, [DATE2a, DATE2b, ...],
521 ...
522 ]
523
524 For example, if the following events are defined:
525
526 2000-01-01 ; 2000-03-21 = Winter
527 2000-03-22 ; 2000-06-21 = Spring
528 2000-02-01 = Event1
529 2000-05-01 = Event2
530 2000-04-01-12:00:00 = Event3
531
532 the following examples illustrate the function:
533
534 Events_List("2000-04-01")
535 => [ 2000040100:00:00, [ Spring ] ]
536
537 Events_List("2000-04-01 12:30");
538 => [ 2000040112:30:00, [ Spring, Event3 ] ]
539
540 Events_List("2000-04-01",0);
541 => [ 2000040100:00:00, [ Spring ],
542 2000040112:00:00, [ Spring, Event3 ],
543 2000040113:00:00, [ Spring ] ]
544
545 Events_List("2000-03-15","2000-04-10");
546 => [ 2000031500:00:00, [ Winter ],
547 2000032200:00:00, [ Spring ]
548 2000040112:00:00, [ Spring, Event3 ]
549 2000040113:00:00, [ Spring ] ]
550
551 If $flag is 1, then a tally of the amount of time given to each
552 event is returned. Time for which two or more events apply is
553 counted for both.
554
555 Events_List("2000-03-15","2000-04-10",1);
556 => { Event3 => +0:0:+0:0:1:0:0,
557 Spring => +0:0:+2:4:23:0:0,
558 Winter => +0:0:+1:0:0:0:0
559 }
560
561 When $flag is 2, a more complex tally with no event counted twice
562 is returned.
563
564 Events_List("2000-03-15","2000-04-10",2);
565 => { Event3+Spring => +0:0:+0:0:1:0:0,
566 Spring => +0:0:+2:4:22:0:0,
567 Winter => +0:0:+1:0:0:0:0
568 }
569
570 The hash contains one element for each combination of events.
571
572 In both of these cases, there may be a hash element with an empty
573 string as the key which contains the amount of time with no events
574 active.
575
576 Date_DayOfWeek
577 $day = Date_DayOfWeek($m,$d,$y);
578
579 Returns the day of the week (1 for Monday, 7 for Sunday).
580
581 Date_SecsSince1970
582 $secs = Date_SecsSince1970($m,$d,$y,$h,$mn,$s);
583
584 Returns the number of seconds since Jan 1, 1970 00:00 (negative if
585 date is earlier).
586
587 Date_SecsSince1970GMT
588 $secs = Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s);
589
590 Returns the number of seconds since Jan 1, 1970 00:00 GMT (negative
591 if date is earlier).
592
593 Date_DaysSince1BC
594 $days = Date_DaysSince1BC($m,$d,$y);
595
596 Returns the number of days since Dec 31, 1BC. This includes the
597 year 0001.
598
599 Date_DayOfYear
600 $day = Date_DayOfYear($m,$d,$y);
601
602 Returns the day of the year (1 to 366)
603
604 Date_NthDayOfYear
605 ($y,$m,$d,$h,$mn,$s) = Date_NthDayOfYear($y,$n);
606
607 Returns the year, month, day, hour, minutes, and decimal seconds
608 given a floating point day of the year.
609
610 All arguments must be numeric. $n must be greater than or equal to
611 1 and less than 366 on non-leap years and 367 on leap years.
612
613 NOTE: When $n is a decimal number, the results are non-intuitive
614 perhaps. Day 1 is Jan 01 00:00. Day 2 is Jan 02 00:00.
615 Intuitively, you might think of day 1.5 as being 1.5 days after Jan
616 01 00:00, but this would mean that Day 1.5 was Jan 02 12:00 (which
617 is later than Day 2). The best way to think of this function is a
618 time line starting at 1 and ending at 366 (in a non-leap year). In
619 terms of a delta, think of $n as the number of days after Dec 31
620 00:00 of the previous year.
621
622 Date_DaysInYear
623 $days = Date_DaysInYear($y);
624
625 Returns the number of days in the year (365 or 366)
626
627 Date_DaysInMonth
628 $days = Date_DaysInMonth($m,$y);
629
630 Returns the number of days in the month.
631
632 Date_WeekOfYear
633 $wkno = Date_WeekOfYear($m,$d,$y,$first);
634
635 Figure out week number. $first is the first day of the week which
636 is usually 1 (Monday) or 7 (Sunday), but could be any number
637 between 1 and 7 in practice.
638
639 NOTE: This routine should only be called in rare cases. Use
640 UnixDate with the %W, %U, %J, %L formats instead. This routine
641 returns a week between 0 and 53 which must then be "fixed" to get
642 into the ISO-8601 weeks from 1 to 53. A date which returns a week
643 of 0 actually belongs to the last week of the previous year. A
644 date which returns a week of 53 may belong to the first week of the
645 next year.
646
647 Date_LeapYear
648 $flag = Date_LeapYear($y);
649
650 Returns 1 if the argument is a leap year Written by David Muir
651 Sharnoff <muir@idiom.com>
652
653 Date_DaySuffix
654 $day = Date_DaySuffix($d);
655
656 Add `st', `nd', `rd', `th' to a date (i.e. 1st, 22nd, 29th). Works
657 for international dates.
658
659 Date_TimeZone
660 $tz = Date_TimeZone;
661
662 This determines and returns the local time zone. If it is unable
663 to determine the local time zone, the following error occurs:
664
665 ERROR: Date::Manip unable to determine Time Zone.
666
667 See the Date::Manip::TZ documentation (DETERMINING THE LOCAL TIME
668 ZONE) for more information.
669
670 Date_ConvTZ
671 $date = Date_ConvTZ($date,$from,$to);
672
673 This converts a date (which MUST be in the format returned by
674 ParseDate) from one time zone to another.
675
676 $from and $to each default to the local time zone. If they are
677 given, they must be any time zone or alias understood by
678 Date::Manip.
679
680 If an error occurs, an empty string is returned.
681
682 Date_NextWorkDay
683 $date = Date_NextWorkDay($date,$off [,$time]);
684
685 Finds the day $off work days from now. If $time is passed in, we
686 must also take into account the time of day.
687
688 If $time is not passed in, day 0 is today (if today is a workday)
689 or the next work day if it isn't. In any case, the time of day is
690 unaffected.
691
692 If $time is passed in, day 0 is now (if now is part of a workday)
693 or the start of the very next work day.
694
695 Date_PrevWorkDay
696 $date = Date_PrevWorkDay($date,$off [,$time]);
697
698 Similar to Date_NextWorkDay.
699
700 Date_NearestWorkDay
701 $date = Date_NearestWorkDay($date [,$tomorrowfirst]);
702
703 This looks for the work day nearest to $date. If $date is a work
704 day, it is returned. Otherwise, it will look forward or backwards
705 in time 1 day at a time until a work day is found. If
706 $tomorrowfirst is non-zero (or if it is omitted and the config
707 variable TomorrowFirst is non-zero), we look to the future first.
708 Otherwise, we look in the past first. In other words, in a normal
709 week, if $date is Wednesday, $date is returned. If $date is
710 Saturday, Friday is returned. If $date is Sunday, Monday is
711 returned. If Wednesday is a holiday, Thursday is returned if
712 $tomorrowfirst is non-nil or Tuesday otherwise.
713
714 For all of the functions which return a date, the format of the
715 returned date is governed by the Printable config variable. If a date
716 is returned, it is in the local time zone, NOT the time zone the date
717 was parsed in.
718
720 The following documents describe various parts of Date::Manip. The
721 following documents describe the basic operation of the Date::Manip
722 package:
723
724 An introduction to the Date::Manip classes and how to configure them:
725
726 Date::Manip::Objects - a basic description of the various
727 Date::Manip modules, and how they
728 work together, and how configuration
729 affects them
730 Date::Manip::Config - information for configuring
731 Date::Manip
732
733 The methods available in each class:
734
735 Date::Manip::Obj - base class (modules listed below
736 inherit the methods defined in this
737 class)
738 Date::Manip::Base - module for doing low-level date
739 operations
740 Date::Manip::TZ - module for working with time zones
741 Date::Manip::Date - date operations
742 Date::Manip::Delta - delta operations
743 Date::Manip::Recur - recurrence operations
744
745 Miscellaneous information:
746
747 Date::Manip::Zones - time zone data included in Date::Manip
748 Date::Manip::Calc - date calculations
749 Date::Manip::Holidays - information on defining and using
750 holidays and events
751
752 Information about the module and administrative things:
753
754 Date::Manip::Migration5to6
755 - information on changes necessary
756 to scripts when upgrading from
757 5.xx to 6.xx
758 Date::Manip::Misc - miscellaneous information about
759 Date::Manip (who should use it;
760 acknowledgements)
761 Date::Manip::Changes5 - backward incompatible changes in
762 Date::Manip 5.xx
763 Date::Manip::Changes5to6- differences between version 5.xx
764 and 6.00 (including information
765 on upgrading)
766 Date::Manip::Changes6 - backward incompatible changes in
767 Date::Manip 6.xx
768 Date::Manip::Problems - common problems and instructions
769 for reporting bugs
770 Date::Manip::Examples - examples of how to use Date::Manip
771
773 This script is free software; you can redistribute it and/or modify it
774 under the same terms as Perl itself.
775
777 Sullivan Beck (sbeck@cpan.org)
778
779
780
781perl v5.12.0 2010-04-27 Date::Manip(3)