git ssb

1+

Daan Patchwork / patchwork



Tree: b6d7ee34ab7b57861dd88fc633ba98bfb721b099

Files: b6d7ee34ab7b57861dd88fc633ba98bfb721b099 / lib / depject / message / html / timestamp.js

830 bytesRaw
1const h = require('mutant/h')
2const nest = require('depnest')
3const moment = require('moment-timezone')
4
5exports.gives = nest('message.html.timestamp')
6exports.needs = nest({
7 'message.sync.timestamp': 'first',
8 'message.sync.root': 'first'
9})
10
11exports.create = function (api) {
12 return nest('message.html.timestamp', timestamp)
13
14 function timestamp (msg, link = true) {
15 if (link) {
16 return h('a.Timestamp', {
17 href: api.message.sync.root(msg) || msg.key,
18 anchor: msg.key,
19 title: moment(api.message.sync.timestamp(msg)).format('LLLL zz')
20 }, moment(api.message.sync.timestamp(msg)).fromNow())
21 } else {
22 return moment(api.message.sync.timestamp(msg)).calendar(null, {
23 sameDay: '[Today]',
24 lastDay: '[Yesterday]',
25 lastWeek: '[Last] dddd'
26 })
27 }
28 }
29}
30

Built with git-ssb-web