Well, here is what I have.
$self->{life_left} = $self->{expire_date} - DateTime->now();where $self->{expire_date} is a DateTime object and $self->{life_left} is a DateTime::Duration object.
Then in the template, I do the following:
<td>[% object.life_left.years %]</td>
Hope this makes sense.
Additionally, I will need to do some rounding on the Duration object (if more then siz months => add year, etc).
Thank you for any ideas you might have.
Arshavir
[EMAIL PROTECTED] wrote:
"DateTime::Format::Duration" may be what you need for this specific problem. Can you show us a few lines of your template?
- Flavio S. Glock
I am running into a snag with usingDateTime::Duration and TT. I think
it's an important issue and am surprised that thereis no info on this
DateTime::Duration's accessoron Google.
Somehow when you try to invoke any of
methods from within a TT template it dies with anerror that comparison
operators are not overloaded in DateTime::Durationand that I should use
DateTime::Duration->compare() to do comparisons.somewhere deep in the
I have tracked this down and it appears that
template processing, TT is doing an 'eq' on aDateTime::Duration object
overload the comparisonand that's throwing an exception.
I am wondering whether it would be very hard to
operators.you just call
If both objects are of DateTime::Duration, then can
compare from within _compare_overload(). And ifthey are not of the same
type, then they are obviously not equal.of comparison,
Or maybe the 'eq' operator could be a special case
what I am trying toimplemented as a separate _eq_overload() subroutine.
Maybe, I am asking for too much, but it seems like
do is fairly mundane.
Thanks for any insights you may have.
Arshavir
