Date-Manip

 view release on metacpan or  search on metacpan

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

=item B<cmp>

   $flag = $dmb->cmp($date1,$date2);

Returns -1, 0, or 1 if date1 is before, the same as, or after date2.

=item B<day_of_week>

   $day = $dmb->day_of_week($date);
   $day = $dmb->day_of_week($ymd);

Returns the day of the week (1 for Monday, 7 for Sunday).

=item B<day_of_year>

   $day = $dmb->day_of_year($ymd);
   $day = $dmb->day_of_year($date);

In the first case, returns the day of the year (1 to 366) for C<($y,
$m, $d)>.  In the second case, it returns a fractional day (1.0 <=
C<$day> < 367.0).  For example, day 1.5 falls on Jan 1, at noon.  The
somewhat non-intuitive answer (1.5 instead of 0.5) is to make the two
forms return numerically equivalent answers for times of 00:00:00
. You can look at the integer part of the number as being the day of
the year, and the fractional part of the number as the fraction of the
day that has passed at the given time.

The inverse operations can also be done:

   $ymd   = $dmb->day_of_year($y,$day);
   $date  = $dmb->day_of_year($y,$day);

If C<$day> is an integer, the year, month, and day is returned. If C<$day>
is a floating point number, it returns the year, month, day, hour,
minutes, and decimal seconds.

C<$day> must be greater than or equal to 1 and less than 366 on non-leap years
or 367 on leap years.

=item B<days_in_month>

   $days = $dmb->days_in_month($y,$m);

Returns the number of days in the month.

   @days = $dmb->days_in_month($y,0);

Returns a list of 12 elements with the days in each month of the year.

=item B<days_in_year>

   $days = $dmb->days_in_year($y);

Returns the number of days in the year (365 or 366)

=item B<days_since_1BC>

   $days = $dmb->days_since_1BC($date);
   $days = $dmb->days_since_1BC($ymd);

Returns the number of days since Dec 31, 1BC. Since the calendar has
changed a number of times, the number returned is based on the current
calendar projected backwards in time, and in no way reflects a true
number of days since then. As such, the result is largely meaningless,
except when called twice as a means of determining the number of days
separating two dates.

The inverse operation is also available:

   $ymd = $dmb->days_since_1BC($days);

Returns the date C<$days> since Dec 31, 1BC. So day 1 is Jan 1, 0001.

=item B<leapyear>

   $flag = $dmb->leapyear($y);

Returns 1 if the argument is a leap year.

=item B<nth_day_of_week>

   $ymd = $dmb->nth_day_of_week($y,$n,$dow);

Returns the C<$n>th occurrence of C<$dow> (1 for Monday, 7 for Sunday) in the
year.  C<$n> must be between 1 and 53 or -1 through -53.

   $ymd = $dmb->nth_day_of_week($y,$n,$dow,$m);

Returns the C<$n>th occurrence of C<$dow> in the given month.  C<$n>
must be between 1 and 5 or it can be -1 through -5.

In all cases, nothing is returned if C<$n> is beyond the last actual
result (i.e. the 5th Sunday in a month with only four Sundays).

=item B<secs_since_1970>

   $secs = $dmb->secs_since_1970($date);

Returns the number of seconds since Jan 1, 1970 00:00:00 (negative if date is
earlier).

   $date = $dmb->secs_since_1970($secs);

Translates number of seconds into a date.

=item B<split>

=item B<join>

The split and join functions are used to take a string containing a common
type of time data and split it into a list of fields. The join function takes
the list and forms it into a string.

The general format for these is:

  $obj    = $dmb->split($type,$string,\%opts);
  $string = $dmb->join($type,$obj,\%opts);

An older format is also supported:

  $obj    = $dmb->split($type,$string,[$no_normalize]);
  $string = $dmb->join($type,$obj,[$no_normalize]);



( run in 1.738 second using v1.01-cache-2.11-cpan-39bf76dae61 )