NAME

Fax::DataFax::DateTime - Perl extension for miscellanous methods.

SYNOPSIS

use Fax::DataFax::DateTime;

No automatically exported routines. You have to specifically to import the methods into your package.

use Fax::DataFax::DateTime qw(:qc_time fmtTime);
use Fax::DataFax::DateTime /:qc_time/;
use Fax::DataFax::DateTime ':qc_time';

Notation and Conventions

$drh    Driver handle object (rarely seen or used in applications)
$h      Any of the $??h handle types above
$rc     General Return Code  (boolean: true=ok, false=error)
$rv     General Return Value (typically an integer)
@ary    List of values returned from the database, typically a row 
        of data
$rows   Number of rows processed (if available, else -1)
$fh     A filehandle
undef   NULL values are represented by undefined values in perl
\%attr  Reference to a hash of attribute values passed to methods

DESCRIPTION

This is a package containing common methods for processing date and time.

Exported routines:

fmtTime    - format times 
cvtTime    - convert time from one format to another
cvtYY2Y4   - convert year from two-digits to four digits
check_user_time - check DataFax user and time

Exported TAGS:

common    => [fmtTime cvtTime cvtYY2Y4],
qc_time   => [check_user_time],
chk_time  => [check_user_time],
cvt_time  => [cvtTime cvtYY2Y4],

Export Tag: common

The :common tag includes methods for dealing with date and time.

use Fax::DataFax::DateTime qw(:common);

It includes the following methods:

  • getLastDateInMonth($dt, $gap, $typ)

    Input variables:

    $dt  - date in the format of YYYYMMDD.hhmmss
    $gap - number of months
    $typ - input type: default - YYYYMM or YYYYMMDD
                       1 - YYMMDD or YYMM
                       5 - YYYY/MM/DD hh:mm:ss

    Variables used or routines called:

    cvtYY2Y4 - convert two-digits to four digits year.

    How to use:

    my $dom = $self->getLastDateInMonth('19990125',2); 

    Return: the last day in a month in the format of YYYYMMLD.

  • get_date_format($r1, $r2, $r3, $ds)

    Input variables:

    $r1 - date range 1: 'min:max'
    $r2 - date range 2: 'min:max'
    $r3 - date range 3: 'min:max'
    $ds - date separator

    Variables used or routines called:

    None. 

    How to use:

    # the $dft = 'MM/DD/YY' 
    my $dft = $self->get_date_format('1:12','1:31','1:2'); 
    # the $dft = 'MM/DD/YYYY' 
       $dft = $self->get_date_format('1:12','1:31','0:2002'); 

    Return: the date format.

Export Tag: qc_time

The :qc_time tag includes methods for dealing with date and time in processing journal and QC files.

use Fax::DataFax::DateTime qw(:qc_time);

It includes the following methods:

  • check_user_time($str, $typ)

    Input variables:

    $str - string in the format of 'dfuser YY/MM/DD hh:mm:ss'
    $typ - time format. default: YY/MM/DD hh:mm:ss
           1 - time is in: YYMMDD.hhmmss
           2 - time is in: YYYYMMDD.hhmmss

    Variables used or routines called: None.

    How to use:

    my ($usr, $tm) = 
      $self->check_user_time('dfuser 99/01/25 14:25:35'); 

    Return: user and time in YYYYMMDD.hhmmss format

  • fmtTime($ptm, $otp)

    Input variables:

    $ptm - Perl time 
    $otp - output type: default - YYYYMMDD.hhmmss 
                         1 - YYYY/MM/DD hh:mm:ss
                         5 - MM/DD/YYYY hh:mm:ss
                        11 - Wed Mar 31 08:59:27 1999

    Variables used or routines called: None

    How to use:

    # return current time in YYYYMMDD.hhmmss
    my $t1 = $self->fmtTime;  
    # return current time in YYYY/MM/DD hh:mm:ss
    my $t2 = $self->fmtTime(time,1);  

    Return: date and time in the format specified.

  • cvtTime($tm, $itp, $otp)

    Input variables:

    $tm  - Time in the format of $itp
    $itp - Input time type 
    $otp - Output type
      Time types: 
      default - YYYYMMDD.hhmmss 
         1 - YYYY/MM/DD hh:mm:ss
         2 - YYYYMMDD_hhmmss
         3 - YYYY.MM.DD hh:mm:ss
         5 - MM/DD/YYYY hh:mm:ss
        11 - WWW Mon DD hh:mm:ss YYYY (Wed Mar 31 08:59:27 1999)
        99 - Perl time, i.e., non-leap second since the epoch

    Variables used or routines called: None

    How to use:

    # return current time in YYYYMMDD.hhmmss
    my $t1 = $self->fmtTime;  
    # return current time in YYYY/MM/DD hh:mm:ss
    my $t2 = $self->fmtTime(time,1);  

    Return: date and time in the format specified.

  • cvtYY2Y4($tm,$itp,$otp)

    Input variables:

    $tm  - Time in the format of $itp
    $itp - Input time type 
    $otp - Output type
      Time types input and output types
               $itp                   $otp
    default - YY                   => YYYY
        1 - YY/MM/DD hh:mm:ss      => YYYY/MM/DD hh:mm:ss
        2 - YYMMDD_hhmmss          => YYYYMMDD_hhmmss
        5 - MM/DD/YY hh:mm:ss      => MM/DD/YYYY hh:mm:ss
       11 - WWW Mon DD hh:mm:ss YY => WWW Mon DD hh:mm:ss YYYY
           (Wed Mar 31 08:59:27 99)   (Wed Mar 31 08:59:27 1999)
       21 - YYMMDD.hhmmss          => YYMMDD.hhmmss
       22 - YYMMDD                 => YYYYMMDD
       23 - YYMM                   => YYYYMM
       24 - YY                     => YYYY

    Variables used or routines called:

    df_param - get DataFax parameters from DataFax.ini

    How to use:

    # return current time in YYYYMMDD.hhmmss
    my $t1 = $self->fmtTime;  
    # return current time in YYYY/MM/DD hh:mm:ss
    my $t2 = $self->fmtTime(time,1);  

    Return: date and time in the format specified.

AUTHOR

Hanming Tu, hanming_tu@yahoo.com

SEE ALSO

DateTime::Precise, Time::Local, perltoot(1), perlobj(1), perlbot(1), perlsub(1), perldata(1), perlsub(1), perlmod(1), perlmodlib(1), perlref(1), perlreftut(1).