Handbook
Glossary
elapsed-time ( seconds -- string )
Vocabulary
calendar
.
format
Inputs
seconds
an
object
Outputs
string
an
object
Definition
IN:
calendar.format
GENERIC:
elapsed-time
( seconds -- string )
Methods
USING:
calendar
calendar.format
;
M:
duration
elapsed-time
duration>seconds
elapsed-time
;
USING:
calendar.format
kernel
make
math
math.parser
sequences
splitting
;
M:
integer
elapsed-time
dup
0
<
[
"negative seconds"
throw
]
when
[
{
{
60
"s"
}
{
60
"m"
}
{
24
"h"
}
{
7
"d"
}
{
52
"w"
}
{
f
"y"
}
}
[
[
first
[
/mod
]
[
dup
]
if*
]
[
second
]
bi
swap
dup
0
>
[
number>string
prepend
,
]
[
2drop
]
if
]
each
drop
]
{
}
make
[
"0s"
]
[
reverse
join-words
]
if-empty
;
USING:
calendar.format
math
;
M:
real
elapsed-time
>integer
elapsed-time
;
USING:
calendar
calendar.format
;
M:
timestamp
elapsed-time
ago
elapsed-time
;