Re: Date Values
- From: "A. Pagaltzis" <pagaltzis gmx de>
- To: gtk-perl list <gtk-perl-list gnome org>
- Subject: Re: Date Values
- Date: Thu, 3 Jun 2004 14:24:17 +0200
* Carl Nygard <cjnygard fast net> [2004-06-03 13:47]:
Use epoch seconds and Date::Manip is your friend.
No, don't use Date::Manip. From the POD [1]:
SHOULD I USE DATE::MANIP
If you look in CPAN, you'll find that there are a number of Date
and Time packages. Is Date::Manip the one you should be using? In
my opinion, the answer is no most of the time. This sounds odd
coming from the author of the software, but read on.
[...]
There are numerous modules for manipulating dates that do more
narrowly defined tasks at least as well. Some of them have an
equally convenient interface. Among the choices:
* POSIX
* Date::Calc
* Time::Piece
* DateTime
The last is the basis of a very complete framework and would be
my favourite for anything slightly more complex. The first would
be my choice for the simple conversion task at hand.
use POSIX qw(strptime strftime);
my $date = "2004-06-03";
my $epoch_time = strptime "%Y-%m-%d", $date;
my $display_date = strftime "%d-%m-%Y", $epoch_time;
A large advantage is that POSIX.pm is part of core, and therefor
doesn't add any external dependencies to the app.
[1] http://search.cpan.org/dist/DateManip/Manip.pod#SHOULD_I_USE_DATE::MANIP
--
Regards,
Aristotle
"If you can't laugh at yourself, you don't take life seriously enough."
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]