Date-Manip

 view release on metacpan or  search on metacpan

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

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]);

but this is deprecated and will be removed in Date::Manip 7.00.  These
are equivalent to:

  $obj    = $dmb->split($type,$string,{ 'nonorm' => $no_normalize });
  $string = $dmb->join($type,$obj,{ 'nonorm' => $no_normalize });

The value of C<$type> determines what type of join/split operation occurs.

Rudimentary error checking is performed with both of these functions
and undef is returned in the case of any error. No error checking is done
on the specific values.

=over 8

=item B<$type = 'date'>

   $date = $dmb->split("date",$string);
   $string = $dmb->join("date",$date);

This splits a string containing a date or creates one from a list reference.
The string split must be of one of the forms:

   YYYYMMDDHH:MN:SS
   YYYYMMDDHHMNSS
   YYYY-MM-DD-HH:MN:SS

The string formed by join is one of the above, depending on the value of
the Printable config variable. The default format is YYYYMMDDHH:MN:SS,
but if Printable is set to 1, YYYYMMDDHHMNSS is produced, and if Printable
is set to 2, the YYYY-MM-DD-HH:MN:SS form is produced.

=item B<$type = 'hms'>

   $hms = $dmb->split("hms",$string);
   $string = $dmb->join("hms",$hms);

This works with the hours, minutes, and seconds portion of a date.

When splitting a string, the string can be of any of the forms:

   H
   H:MN
   H:MN:SS
   HH
   HHMN
   HHMNSS

Here, H is a 1 or 2 digit representation of the hours but HH (and all
other fields) are two digit representations.

The string formed by the join function will always be of the form HH:MN:SS.

The time must be between 00:00:00 and 24:00:00.

=item B<$type = 'offset'>

   $offset = $dmb->split("offset",$string);
   $string = $dmb->join("offset",$offset);

An offset string should have a sign (though it is optional if it is
positive) and is any of the forms:

   +H
   +H:MN
   +H:MN:SS
   +HH
   +HHMN
   +HHMNSS

Here, H is a 1 or 2 digit representation of the hours. All other fields are
two digit representations.

The string formed by the join function will always be of the form
+HH:MN:SS.

The offset must be between -23:59:59 and +23:59:59 .

=item B<$type = 'time'>

   $time = $dmb->split("time",$string,\%opts]);
   $string = $dmb->join("time",$time,\%opts);



( run in 0.734 second using v1.01-cache-2.11-cpan-71847e10f99 )