From 107de1d36ed7aa28be54bc4850f673e1a18c154b Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Thu, 30 Jul 2015 08:46:44 -0700 Subject: [PATCH] hacker-news: add relative timestamp on posts. --- extra/hacker-news/hacker-news.factor | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/extra/hacker-news/hacker-news.factor b/extra/hacker-news/hacker-news.factor index c22a77ba44..091c5f9f8d 100644 --- a/extra/hacker-news/hacker-news.factor +++ b/extra/hacker-news/hacker-news.factor @@ -1,9 +1,11 @@ ! Copyright (C) 2012 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs classes.tuple colors.constants -colors.hex combinators concurrency.combinators formatting fry -hashtables http.client io io.styles json json.reader kernel make -math math.parser sequences splitting ui urls ; + +USING: accessors assocs calendar calendar.elapsed +colors.constants colors.hex combinators concurrency.combinators +formatting fry hashtables http.client io io.styles json.reader +kernel make math math.parser sequences ui urls ; + IN: hacker-news [ post>url host>> " (" ")" surround write-text nl ] [ "score" of " %d points" sprintf write-text ] [ 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 [ " | " write-text