• Home
  • Services
    • Consultancy
    • Custom Software Solutions
    • Systems Adminsitration
    • SCM
      • Clearcase
      • Multisite
      • Clearquest
      • Release Managment
      • CVS
    • Web Applications
    • Customers
  • Publications
    • Clearcase
      • Triggers
      • Open Source Builds
    • Clearquest
      • Clearquest Daemon
      • DB Conversions
    • Systems Admin
      • Unix/Linux
      • Windows
    • Scripting
      • Perl
      • PHP
      • ECRDig
  • About
    • Services
    • Our People
    • Our Philosophy
    • Contact Us
 

ClearSCM Inc.

You are viewing an unstyled version of this page. Either your browser does not support Cascading Style Sheets (CSS) or CSS styling has been disabled.

NAME DateUtils.pm

Simple date/time utilities

VERSION

Author

Andrew DeFaria <Andrew@ClearSCM.com>

Revision

Revision 1.15

Created

Thu Jan 5 11:06:49 PST 2006

Modified

Modifed 2008/02/29 15:08:56

SYNOPSIS

Simple date and time utilities for often used date/time functionality.

  my $ymd = YMD;
  my $ymdhm = YMDHM;
  my $timestamp = timestamp;

DESCRIPTION

Often you just want to simply and quickly get date or date and time in a YMD or YMDHM format. Note the YMDHM format defined here is YMD\@H:M and is not well suited for a filename. The timestamp routine returns YMD_HM.

ROUTINES

The following routines are exported:

Age ($timestamp)

Determines how old something is given a timestamp

Parameters:

$timestamp:

Timestamp to age from (Assumed to be earlier than today)

Returns:

Number of days between $timestamp and today

FormatDate ($date)

Formats date

Parameters:

$date:

Date in YYYYMMDD

Returns:

Returns a date in MM/DD/YYYY format

FormatTime ($time)

Formats Time

Parameters:

$time:

Time in in HH:MM format (24 hour format)

Returns:

Time in HH:MM [Am|Pm] format

MDY ($time)

Returns MM/DD/YYYY for $time

Parameters:

$time:

Time in Unix time format (Default: current time)

Returns:

Date in MM/DD/YYYY

SQLDatetime2UnixDatetime ($sqldatetime)

Converts an SQL formatted date to a Unix (localtime) formatted date)

Parameters:

$sqldatetime:

Date and time stamp in SQL format

Returns:

Returns a Unix formated date and time (a la localtime)

SubtractDays ($timestamp, $nbr_of_days)

Subtracts $nbr_of_days from $timestamp

Parameters:

$timestamp:

Timestamp to subtract days from

$nbr_of_days:

Number of days to subtract from $timestamp

Returns:

SQL format date $nbr_of_days ago

Today2SQLDatetime ($datetime)

Returns today's date in an SQL format

Parameters:

None

Returns:

SQL formated time stamp for today

UnixDatetime2SQLDatetime ($datetime)

Converts a Unix (localtime) date/time stamp to an SQL formatted date/time stamp

Parameters:

$datetime:

Unix formated date time stamp

Returns:

SQL formated time stamp

YMD ($time)

Returns the YMD in a format of YYYYMMDD

Parameters:

$time:

Time to convert to YYYYMMDD (Default: Current time)

Returns:

Date in YYYYMMDD format

YMDHM ($time)

Returns the YMD in a format of YYYYMMDD@HH:MM

Parameters:

$time:

Time to convert to YYYYMMDD@HH:MM (Default: Current time)

Returns:

Date in YYYYMMDD@HH:MM format

YMDHMS ($time)

Returns the YMD in a format of YYYYMMDD@HH:MM:SS

Parameters:

$time:

Time to convert to YYYYMMDD@HH:MM:SS (Default: Current time)

Returns:

Date in YYYYMMDD@HH:MM:SS format

timestamp ($time)

Returns the YMD in a format of YYYYMMDD_HHMM

Parameters:

$time:

Time to convert to YYYYMMDD_HHMMSS (Default: Current time)

Returns:

Date in YYYYMMDD_HHMMSS format

DEPENDENCIES

  Display

INCOMPATABILITIES

None yet...

BUGS AND LIMITATIONS

There are no known bugs in this module.

Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.

LICENSE AND COPYRIGHT

This Perl Module is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This Perl Module is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (http://www.gnu.org/copyleft/gpl.html) for more details.

You should have received a copy of the GNU General Public License along with this Perl Module; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. reserved.