Show time delta in perl's template toolkit -
Show time delta in perl's template toolkit -
i want supply integer template::toolkit template. integer represents number of seconds elapsed.
i want format number so:
1 => "1 sec ago" 2 => "2 seconds ago" 43342 => "12 hours, 2 minutes ago" # ignoring remaining 42 seconds 4333342 => "1 month, 19 days ago" # ignoring remaining 17h, 42m & 22s
i can't find tt plugin this.
will need formatting outside of tt?
thanks
there's code comes close, if utilize datetime::duration
represent duration. datetime::format::human::duration
can of need, tend include additional parts of duration beyond interested in. because formatter object, duration, both can injected template variables. utilize duration units straight in template, lot of logic.
time::duration
improve precision thing, provide limit 2 unit types, doesn't have object interface, can't inject straight variable, might basis custom filter.
if me, i'd wrap function need new formatting class takes time need, create instance, , inject variable template. it's typically easier unit test way.
perl time template-toolkit
Comments
Post a Comment