hacker-news: add relative timestamp on posts.

db4
John Benediktsson 2015-07-30 08:46:44 -07:00
parent 64d8c0ccc0
commit 107de1d36e
1 changed files with 12 additions and 5 deletions

View File

@ -1,9 +1,11 @@
! Copyright (C) 2012 Doug Coleman. ! Copyright (C) 2012 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs classes.tuple colors.constants
colors.hex combinators concurrency.combinators formatting fry USING: accessors assocs calendar calendar.elapsed
hashtables http.client io io.styles json json.reader kernel make colors.constants colors.hex combinators concurrency.combinators
math math.parser sequences splitting ui urls ; formatting fry hashtables http.client io io.styles json.reader
kernel make math math.parser sequences ui urls ;
IN: hacker-news IN: hacker-news
<PRIVATE <PRIVATE
@ -55,7 +57,12 @@ PRIVATE>
[ post>url host>> " (" ")" surround write-text nl ] [ post>url host>> " (" ")" surround write-text nl ]
[ "score" of " %d points" sprintf write-text ] [ "score" of " %d points" sprintf write-text ]
[ dup "by" of [ " by " write-text [ "by" of ] [ post>user-url ] bi write-link ] [ drop ] if ] [ dup "by" of [ " by " write-text [ "by" of ] [ post>user-url ] bi write-link ] [ drop ] if ]
! [ dup postedAgo>> [ " " write-text postedAgo>> write-text ] [ drop ] if ] [
"time" of [
" " write-text now timestamp>unix-time
swap - relative-time write-text
] when*
]
[ [
dup "decendants" of [ dup "decendants" of [
" | " write-text " | " write-text