Lori713 has asked for the wisdom of the Perl Monks concerning the following question:
Other than using Date::Calc (which we don't have loaded and I'd like to avoid asking the dba's to load modules if possible - don't ask - politics) and Date::Manip which I hear is *really* *really* *really* impressive in it's flexibility but far beyond what I need (sledgehammer vs. toothpick?)... any ideas on how to better (more accurately) count the number of months since 6/30/99?
P.S.: $elapsed_mons returns "56" which is correct (as of today). Thanks for any advice/insight you can provide.
#!/usr/local/bin/perl5_8 use strict; use warnings; use Time::Local; #snipped stuff #Calculate elapsed months since today my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; my $mo = $mon + 1; my $dy = $mday; my $yr = $year + 1900; #yep, extra steps but makes it clearer to me... my $now_date = "$yr/$mo/$dy"; my($ny, $nm, $nd) = $now_date =~ m<^(\d+)/(\d+)/(\d+)$>; my $ntime = timelocal(0, 0, 12, $nd, $nm-1, $ny); my $then_date = "1999/06/30"; # rpts will never go back beyond this d +ate my($ty, $tm, $td) = $then_date =~ m<^(\d+)/(\d+)/(\d+)$>; my $ttime = timelocal(0, 0, 12, $td, $tm-1, $ty); my $elapsed_mons = int(($ntime - $ttime)/( 60 * 60 * 24 * 30)); #use $elapsed_mons to generate drop down list of available report mont +hs #snipped stuff
Lori
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Time::Local - calculate months elapsed
by liz (Monsignor) on Feb 24, 2004 at 18:53 UTC | |
by Lori713 (Pilgrim) on Feb 24, 2004 at 21:11 UTC | |
|
Re: Time::Local - calculate months elapsed
by Limbic~Region (Chancellor) on Feb 24, 2004 at 18:30 UTC | |
|
Re: Time::Local - calculate months elapsed
by waswas-fng (Curate) on Feb 24, 2004 at 18:24 UTC |