in reply to Re: More Help please ? Time::Piece errors?
in thread Time::Piece errors?

In the words and stile of a grateful man:-
Thank you, and thank you again.

I have made the changes that everybody kindly suggested
And thanks to all who noticed my incorrect calculations.
This steams from to points.
1st, i copied bits of the code of different help notes and tried to cobble it all together.
2nd, I'm honestly not sure how this code is working when it comes to the lines of
$months = int($diff->months); #i know int insure an integer.
In this case dumping the number of seconds that are left over?

$diff -= $months * ONE_MONTH; # but this line confuses me?

Where does the "ONE_MONTH" variable get pulled from?
ie how do i know if i got the right name?

is it lifted from the Time::Piece pm
ie this bit:
use constant 'c_sec' => 0;
use constant 'c_min' => 1;
use constant 'c_hour' => 2;
use constant 'c_mday' => 3;
use constant 'c_mon' => 4;
use constant 'c_year' => 5;
use constant 'c_wday' => 6;
use constant 'c_yday' => 7;
use constant 'c_isdst' => 8;
use constant 'c_epoch' => 9;
use constant 'c_islocal' => 10;

or is my understanding of this as closes to my understanding of rocket since.

One thing i using code and another understanding it :(

One final thing If I may. I have copy my final code below. Can anybody see any other faults I have missed/misunderstood?

Final I would like to thank again everybody who has help me understand this.

Regards,
Gareth

#!/usr/bin/perl use Time::Piece; use Time::Seconds; $before = Time::Piece->strptime("Thu Apr 1 10:00:00 2003", "%a %b %e % +H:%M:%S %Y"); $now = localtime(time) + $before->tzoffset; print "Time now is:$now\n"; # gives time format "Thu May 1 13:11:11 +2003" print "Time before:$before\n"; # gives time format of "Thu May 1 13:1 +1:11 2003" # (dont forget timezone) $diff = $now - $before; $years = int($diff->years); $diff -= $years * ONE_YEAR; $months = int($diff->months); $diff -= $months * ONE_MONTH; $days = int($diff->days); $diff -= $days * ONE_DAYS; $hours = int($diff->hours); $diff -= $hours * ONE_HOUR; $minutes = int($diff->minutes); $diff -= $minute * ONE_MINUTE; print "$years years, $months months, $days days, $hours hours, $minute +s minutes since $before\n";