Slackware::Slackget::Date - A class to manage date for slack-get.
Version 1.0.0
This class is an abstraction of a date. It centralyze all operation you can do on a date (like comparisons)
use Slackware::Slackget::Date; my $date = Slackware::Slackget::Date->new('day-name' => Mon, 'day-number' => 5, 'year' => 2005); $date->year ; my $status = $date->compare($another_date_object); if($date->is_equal($another_date_object)) { print "Nothing to do : date are the same\n"; }
The constructor take the followings arguments :
day-name => the day name in : Mon, Tue, Wed, Thu, Fri, Sat, Sun day-number => the day number from 1 to 31. WARNINGS : there is no verification about the date validity ! month-name => the month name (Jan, Feb, Apr, etc.) month-number => the month number (1 to 12) hour => the hour ( a string like : 12:52:00). The separator MUST BE ':' year => a chicken name...no it's a joke the year (ex: 2005). use-approximation => in this case the comparisons method just compare the followings : day, month and year. (default: no)
You have to manage by yourself the date validity, because this class doesn't check the date validity. The main reason of this, is that this class is use to compare the date of specials files.
So I use the predicate that peoples which make thoses files don't try to do a joke by a false date.
my $date = Slackware::Slackget::Date->new( 'day-name' => Mon, 'day-number' => 5, 'year' => 2005, 'month-number' => 2, 'hour' => '12:02:35', 'use-approximation' => undef );
This mathod compare the current date object with a date object passed as parameter.
my $status = $date->compare($another_date);
The returned status is :
0 : $another_date is equal to $date 1 : $date is greater than $another_date 2 : $date is lesser than $another_date
Take another date object as parameter and return TRUE (1) if this two date object are equal (if compare() return 0), and else return false (0).
if($date->is_equal($another_date)){ ...do something... }
WARNING : this method also return undef if $another_date is not a Slackware::Slackget::Date object, so be carefull.
This method is call by the constructor to resolve the month equivalence (name/number).
This method affect 0 to all undefined numerical values.
This method fill the Slackware::Slackget::Date object with the today parameters. This method fill the followings object value : day-number, year, month-number,
$date->today ; print "Today date is ",$date->to_string,"\n";
return the date as an XML encoded string.
$xml = $date->to_XML();
return the date as an HTML encoded string.
$xml = $date->to_HTML();
return the date as a plain text string.
print "Date of the package is ", $package->date()->to_string,"\n";
return the year
my $string = $date->year;
return the monthname
my $string = $date->monthname;
return the 'day-name'
my $string = $date->'day-name';
return the hour
my $string = $date->hour;
return the daynumber
my $string = $date->daynumber;
return the monthnumber
my $string = $date->monthnumber;
DUPUIS Arnaud, <a.dupuis@infinityperl.org>
<a.dupuis@infinityperl.org>
Please report any bugs or feature requests to bug-Slackware-Slackget@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Slackware-Slackget. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-Slackware-Slackget@rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Slackware::Slackget
You can also look for information at:
Infinity Perl website
http://www.infinityperl.org
slack-get specific website
http://slackget.infinityperl.org
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Slackware-Slackget
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Slackware-Slackget
CPAN Ratings
http://cpanratings.perl.org/d/Slackware-Slackget
Search CPAN
http://search.cpan.org/dist/Slackware-Slackget
Thanks to Bertrand Dupuis (yes my brother) for his contribution to the documentation.
Copyright 2005 DUPUIS Arnaud, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Slackware::Slackget, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Slackware::Slackget
CPAN shell
perl -MCPAN -e shell install Slackware::Slackget
For more information on module installation, please visit the detailed CPAN module installation guide.