Handbook
Glossary
duration>human-readable ( duration -- string )
Vocabulary
calendar
.
format
Inputs
duration
an
object
Outputs
string
an
object
Definition
USING:
calendar
combinators
kernel
make
math
math.parser
sequences
;
IN:
calendar.format
:
duration>human-readable
( duration -- string )
[
{
[
duration>years
>integer
[
[
number>string
]
[
1
>
" years"
" year"
?
append
,
]
bi
]
unless-zero
]
[
duration>days
>integer
365
mod
[
[
number>string
]
[
1
>
" days"
" day"
?
append
,
]
bi
]
unless-zero
]
[
duration>hours
>integer
24
mod
[
[
number>string
]
[
1
>
" hours"
" hour"
?
append
,
]
bi
]
unless-zero
]
[
duration>minutes
>integer
60
mod
[
[
number>string
]
[
1
>
" minutes"
" minute"
?
append
,
]
bi
]
unless-zero
]
[
duration>seconds
>integer
60
mod
[
number>string
" seconds"
append
,
]
unless-zero
]
}
cleave
]
{
}
make
[
"0 seconds"
]
[
unclip-last-slice
over
empty?
[
nip
]
[
[
", "
join
]
[
" and "
glue
]
bi*
]
if
]
if-empty
;