A custom dayhrminsec(TIME) function

I needed a nice way to get a readout of various values of seconds that could be anywhere from 1 or 2 seconds to several thousand seconds. My solution will give an appropriate readout depending on the number of seconds involved. Here is the code in case anyone else needs a similar solution:

dayhrminsec(TIME)


Parameters

This function has one parameter:

time – the number of seconds.


Description

The dayhrminsec( function converts a time (number of seconds) into an appropriate expanded text value showing days, hours, minutes and seconds while eliminating any element with a 0 value.

dayhrminsec(597445) ☞ 6 days:21 hr:57 min:25 sec
dayhrminsec(9248) ☞ 2 hr:34 min:08 sec
dayhrminsec(86410) ☞ 1 day:10 sec

Note: This function is equivalent to:

arraystrip(arrayfilter(?(val(timepattern(time,“hh”))>23,
pattern(int(time/86400),"# day~")+
timepattern(time-(int(time/86400)*86400),":hh hr:mm min:ss sec"),
timepattern(time,“hh hr:mm min:ss sec”)), “:”,
{?(val(striptonum(import()))=0,"",import())}),":")

A few suggestions on reducing the number of datatype changes.

Replace val(timepattern(time,“hh”))>23 with time≥86400
Replace int(time/86400) with time\86400
Replace time-(int(time/86400)*86400 with time mod 86400

Thanks for cleaning up my sloppy code Dave. I was not aware of the backslash to performs integer division. The other two improvements are things I probably should have hit upon myself. Here is the corrected code for this function with your suggestions incorporated:

arraystrip(arrayfilter(?(time≥86400,
pattern(time\86400,"# day~")+
timepattern(time mod 86400,":hh hr:mm min:ss sec"),
timepattern(time,“hh hr:mm min:ss sec”)), “:”,
{?(val(striptonum(import()))=0,"",import())}),":")