Date-Manip

 view release on metacpan or  search on metacpan

lib/Date/Manip/Holidays.pod  view on Meta::CPAN

# Copyright (c) 1995-2026 Sullivan Beck. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

=pod

=head1 NAME

Date::Manip::Holidays - describes holidays and events

=head1 SYNOPSIS

This describes the Holidays and Events sections of the config file,
and how they are used.

Holidays and events are specific days that are named. Holidays are
used in business mode calculations, events are not. Events may be used
for other calendaring operations.

=head1 HOLIDAYS

The holiday section of the config file is used to define holidays.  Each
line is of the form:

   STRING = HOLIDAY

HOLIDAY is the name of the holiday or it can be blank.

If HOLIDAY is blank, the holiday is unnamed, but still treated as a
holiday.  For example, in the US, the day after Thanksgiving is often
a work holiday though it is not named.

HOLIDAY should be unique in most cases.  The only exception is if the
holiday definition is complex enough that it is impossible to describe
it with one STRING.  In this case, multiple lines may be given with
different values of STRING but the same value for HOLIDAY, and in these
cases, the first STRING that matches a given year will be used.  This
situation is described in more detail below.

NOTE: It is not allowed to have unnamed holidays that require multiple
definitions, so a name will have to be assigned in that case.

STRING is a string which can be parsed to give a valid date. It can be any
of the following forms:

=over 4

=item B<A full date>

Specific holidays can be set which occur only a single time.

   May 5, 2000                     = A one-time-only holiday

Any format parseable by C<Date::Manip::Date::parse_date> can be used.

There is one caveat to using a full date.  Date::Manip assumes that
most holidays will appear once per year, so if you were to explicitly
defined New Years (observed) as:

   2004-12-31                      = New Year's Day

then it would assume that it had found the occurrence of New Year's for
2004 when in fact, this is the 2005 occurrence.

Full date specifications should only be used as a last resort, and
probably only if you will explicitly specify all occurrence of the
holiday.

=item B<A date without a year>

Some holidays occur every year on the same day. These can be defined
using the simple lines:

   Jan 1                           = New Year's Day
   Jul 4th                         = Independence Day
   fourth Thu in Nov               = Thanksgiving

These dates must be written in a form which can be parsed as a full

lib/Date/Manip/Holidays.pod  view on Meta::CPAN

C<Date::Manip::Date::list_holidays> method (or the C<Date_IsHoliday>
function), you can get a list of all names that the date contains.

=item B<Complex holiday descriptions>

Occasionally, you cannot describe a holiday using a single line.  For
example, the US Federal Reserve banks use a complex holiday description
where:

   For holidays falling on Saturday, Federal Reserve Banks
   and Branches will be open the preceding Friday. For holidays
   falling on Sunday, all Federal Reserve Banks and Branches
   will be closed the following Monday.

Since Saturday is not a business day, the DWD modifier will not work.
For these, you need a more complicated definition.

The following definitions both work:

   # Saturday
   1*1:0:1:0:0:0*NBD,BD1,IBD,FD1   = New Year's Day
   # Sunday (observed Monday)
   1*1:0:1:0:0:0*NBD,BD1,NBD,FD2   = New Year's Day
   # M-F
   1*1:0:1:0:0:0*IBD               = New Year's Day

and

   # Saturday
   1*1:0:1:0:0:0*IW6               = New Year's Day
   # Sunday (observed Monday)
   1*1:0:1:0:0:0*IW7,FD1           = New Year's Day
   # M-F
   1*1:0:1:0:0:0*IBD               = New Year's Day

=back

=head1 EVENTS

The Events section of the config file is similar to the Holiday section.
It is used to name certain days or times, but there are a few important
differences:

=over 4

=item B<Events can be assigned to any time and duration>

All holidays are exactly 1 day long.  They are assigned to a period
of time from midnight to midnight.

Events can be based at any time of the day, and may be of any duration.

=item B<Events don't affect business mode calculations>

Unlike holidays, events are completely ignored when doing business
mode calculations.

=back

Whereas holidays were added with business mode math in mind, events
were added with calendar and scheduling applications in mind.

Every line in the events section is of the form:

   EVENT = NAME

where NAME is the name of the event, and EVENT defines when it occurs
and its duration.  An EVENT can be defined in the following ways:

   Date
   YMD
   YM
   Recur

   Date  ; Date
   YMD   ; YMD
   YM    ; YM
   Date  ; Delta
   Recur ; Delta

Date refers to a full date/time (and is any string that can be parsed
by C<Date::Manip::Date::parse>). YMD is any string which can be parsed by
C<Date::Manip::Date::parse_date>. YM is any string which can be parsed by
the parse_date method to give a date in the current year. Recur is a
partial or fully specified recurrence. Delta is any string that can be
parsed to form a delta.

With the "Date" form, or the "Recur" form, the event starts at the
time (or times) specified by the date or recurrence, and last 1 hour
long.  With the "YMD" and "YM" forms, the event occurs on the given
day, and lasts all day.

With all of the two part forms ("Date;Date", "YM;YM", etc.), the event
starts at the first date and goes to the second date, or goes an
amount of time specified by the delta.

The "YMD;YMD" and "YM;YM" forms means that the event lasts from the
start of the first date to the end of the second. In the Date;Date
form, the event goes from the first date to the second date
inclusive. In other words, both dates are in the event. In the
"Date;Delta" and "Recur;Delta" forms, the Delta tells the length of
the event. Also, in the Date;Date form, the second date may NOT be
expressed as a delta.

Currently, having an event longer than 1 year is NOT supported, but no
checking is done for this.

=head1 KNOWN BUGS

None known.

=head1 BUGS AND QUESTIONS

Please refer to the L<Date::Manip::Problems> documentation for
information on submitting bug reports or questions to the author.

=head1 SEE ALSO

L<Date::Manip>        - main module documentation

=head1 LICENSE



( run in 0.722 second using v1.01-cache-2.11-cpan-f52f0507bed )