relative-time-offset ( seconds -- string )


Vocabulary
calendar.format

Inputs
secondsan object


Outputs
stringan object


Definition


: relative-time-offset ( seconds -- string )
abs {
{ [ dup 1 < ] [ drop "just now" ] }
{ [ dup 60 < ] [ drop "less than a minute" ] }
{ [ dup 120 < ] [ drop "about a minute" ] }
{ [ dup 2700 < ] [ 60 /i "%d minutes" sprintf ] }
{ [ dup 7200 < ] [ drop "about an hour" ] }
{ [ dup 86400 < ] [ 3600 /i "%d hours" sprintf ] }
{ [ dup 172800 < ] [ drop "1 day" ] }
[ 86400 /i "%d days" sprintf ]
} cond ;