bazz
11-18-2009, 07:25 PM
I am on the last date manipulation but I am stuck.
I have year, month and day_of_year and I need to compile an iso format date eg 2009-11-17 currently I have got it to 2009-11-289 :eek: ( It has been a long month but that is kickin' the **** out of it :) )
So can any of you please point me to where there is a conversion in one of the date modules. I have loked in Date:Parse, Date:Calc and as a panic choice; Date:Format. I can't see it or several which in combination might do it.:confused:
here is the code so you can see what I have been up to
my ($first_year, $first_month, $first_day) = split /-/ , $first_date, 3;
my ($last_year, $last_month, $last_day) = split /-/ , $last_date, 3;
my $Dd = '30'; #number_of_days_to_display
#First_doy
my $start_doy = Day_of_Year( $first_year, $first_month, $first_day );
#last_doy
my $last_doy = Day_of_Year( $last_year, $last_month, $last_day );
#calculate last doy from start date for $Dd days
my $number_of_days_to_show = ( $start_doy + $Dd ); # number_of_days_to_show
#Days In first Year
my $days_in_first_year = Days_in_Year( $first_year, '12' );
my $month;
my $year;
my $count=0;
foreach my $day_number ($start_doy .. $last_doy)
{
$count++;
print qq( doy = $day_number :: count = $count <br /> );
# work out the year and month here.
#if day_number exceeds days_in_year reset to zero
if ($day_number == $days_in_first_year){
$count=001;
}
#if day_number exceeds days_in_year use $last_year and $last_month
if ( $day_number > $days_in_first_year ) {
$year = $last_year;
$month = $last_month;
} else {
$month = $first_month;
$year=$first_year;
}
#set the date (01 - 31) from day_of_year
print qq( $count=$count : day_number = $day_number <br /> );
bazz
I have year, month and day_of_year and I need to compile an iso format date eg 2009-11-17 currently I have got it to 2009-11-289 :eek: ( It has been a long month but that is kickin' the **** out of it :) )
So can any of you please point me to where there is a conversion in one of the date modules. I have loked in Date:Parse, Date:Calc and as a panic choice; Date:Format. I can't see it or several which in combination might do it.:confused:
here is the code so you can see what I have been up to
my ($first_year, $first_month, $first_day) = split /-/ , $first_date, 3;
my ($last_year, $last_month, $last_day) = split /-/ , $last_date, 3;
my $Dd = '30'; #number_of_days_to_display
#First_doy
my $start_doy = Day_of_Year( $first_year, $first_month, $first_day );
#last_doy
my $last_doy = Day_of_Year( $last_year, $last_month, $last_day );
#calculate last doy from start date for $Dd days
my $number_of_days_to_show = ( $start_doy + $Dd ); # number_of_days_to_show
#Days In first Year
my $days_in_first_year = Days_in_Year( $first_year, '12' );
my $month;
my $year;
my $count=0;
foreach my $day_number ($start_doy .. $last_doy)
{
$count++;
print qq( doy = $day_number :: count = $count <br /> );
# work out the year and month here.
#if day_number exceeds days_in_year reset to zero
if ($day_number == $days_in_first_year){
$count=001;
}
#if day_number exceeds days_in_year use $last_year and $last_month
if ( $day_number > $days_in_first_year ) {
$year = $last_year;
$month = $last_month;
} else {
$month = $first_month;
$year=$first_year;
}
#set the date (01 - 31) from day_of_year
print qq( $count=$count : day_number = $day_number <br /> );
bazz