NAME
DateStamp - A simple OO interface to current system time and date.
VERSION
This document describes DateStamp version 1.0.4
SYNOPSIS
use DateStamp;
my $date_obj = DateStamp->new();
my $year = $date_obj->return_year(length=>'long'); # $year = 2005
my $day = $date_obj->return_day(format=>'numeric');# day = 27
my $time = $date_obj->return_time(format=>'12', length=>'short'); # $time = 5:12 p.m.
my $date = $date_obj->return_date(format=>'yyyymmdd'); # $date = 20051127
DESCRIPTION
This module provides a simple OO interface to current system time and date information. The module provides not only access to individual components of localtime, but also several frequently used date format combinations (e.g., localtime, yyyymmdd, mm-dd-yyyy, month-day-year). See return_date under INTERFACE section for full list of date formats.
INTERFACE
The following methods are supported:
new
new: Class constructor; no arguments are sent to this method. The new method must be called everytime a snapshot of the current system time/date is desired.
my $date_obj = DateStamp->new();
return_year
return_year: This method will return the numeric value of the current year. Two possible return formats are available: short & long.
$date_obj->return_year(length=>'short'); # 05
$date_obj->return_year(length=>'long'); # 2005
return_month
return_month: This method will return either an alpha or numeric value for the current month in a variety of formats.
$date_obj->return_month(format=>'alpha', length=>'short'); # Nov
$date_obj->return_month(format=>'alpha', length=>'long'); # November
$date_obj->return_month(format=>'numeric'); # 11
return_day
return_day: This method will return either an alpha or numeric value for the current day in a variety of formats.
$date_obj->return_day(format=>'alpha', length=>'short'); # Sun
$date_obj->return_day(format=>'alpha', length=>'long'); # Sunday
$date_obj->return_day(format=>'numeric'); # 27
return_time
return_time: This method will return a variety of time formats. The time in this sense is literally a "timestamp", in that it captures the time at the moment the date object is created--and *not* when the method is called.
$date_obj->return_time(format=>'12', length=>'short'); # 12:56 a.m.
$date_obj->return_time(format=>'12', length=>'long' ); # 12:56:32 a.m.
$date_obj->return_time(format=>'24', length=>'short'); # 00:56
$date_obj->return_time(format=>'24', length=>'long' ); # 00:56:32
$date_obj->return_time(format=>'localtime' ); # Sun Nov 27 00:13:56 2005
return_date
return_date: This method provides serveral frequently used, pre-compiled date combinations. The combinations are not meant to be exhaustive, as other combinations can be arrived at by combining the aforementioned month/day/year/timestamp methods. Both the "yyyymmdd" & "mmddyyyy" formats accept a "glue" argument, placing a provided symbol between month, day, and year.
$date_obj->return_date(format=>'yyyymmdd'); # 20051127
$date_obj->return_date(format=>'yyyymmdd', glue=>'-'); # 2005-11-27
$date_obj->return_date(format=>'mmddyyyy'); # 11272005
$date_obj->return_date(format=>'mmddyyyy', glue=>'/'); # 11/27/2005
$date_obj->return_date(format=>'month-day-year'); # November 27, 2005
$date_obj->return_date(format=>'mon-day-year'); # Nov 27, 2005
$date_obj->return_date(format=>'weekday-month-day-year'); # Monday, November 27, 2005
$date_obj->return_date(format=>'month-day'); # November 27
$date_obj->return_date(format=>'mon-day'); # Nov 27
DIAGNOSTICS
A user may encounter error messages associated with this module if required method arguments are malformed or missing.
DateStamp reports: Bad/missing "format" argument.
-
[A user has invoked a method that requires a "format" argument of type valid for the method called. Check spelling, case (lower-case required), and argument types associated with the method in question.]
DateStamp reports: Bad/missing "length" argument.
-
[A user has invoked a method that requires a "length" argument of type valid for the method called. Check spelling, case (lower-case required), and argument types associated with the method in question.]
CONFIGURATION AND ENVIRONMENT
DateStamp requires no configuration files or environment variables.
DEPENDENCIES
This module calls a few others: strict; warnings; Carp; version.
INCOMPATIBILITIES
None reported.
BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to bug-date-current@rt.cpan.org
, or through the web interface at http://rt.cpan.org.
SEE ALSO
There are several heavy-weight date/time modules in CPAN. Try a search for DateTime or Date in CPAN for a list of alternatives.
ACKNOWLEDGMENTS
Yup, this is my first CPAN module; I wanted to contribute something very simple to start with. Thanks to Andy Lester for his presentation "The A-Z Guide To Becoming a CPAN Author" at the St. Louis Perl Monger chapter meeting in November, 2005. His insight helped greatly in illuminating some dark areas of my skill-set. Andy's talk also galvanized me to finally contribute something to CPAN after 8 years of perl programming.
AUTHOR
Todd Wylie
<perldev@monkeybytes.org>
LICENSE AND COPYRIGHT
Copyright (c) 2005, Todd Wylie <perldev@monkeybytes.org>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
NOTE
This software was written using the latest version of GNU Emacs, the extensible, real-time text editor. Please see http://www.gnu.org/software/emacs for more information and download sources.