git ssb

1+

Daan Patchwork / patchwork



Tree: 703b5de55b4f80cf231d914b9257bc81cd59ceef

Files: 703b5de55b4f80cf231d914b9257bc81cd59ceef / lib / message / html / timestamp.js

591 bytesRaw
1const h = require('mutant/h')
2const moment = require('moment-timezone')
3const getTimestamp = require('../../get-timestamp')
4const getRoot = require('../sync/root')
5
6module.exports = function timestamp (msg, link = true) {
7 if (link) {
8 return h('a.Timestamp', {
9 href: getRoot(msg) || msg.key,
10 anchor: msg.key,
11 title: moment(getTimestamp(msg)).format('LLLL zz')
12 }, moment(getTimestamp(msg)).fromNow())
13 } else {
14 return moment(getTimestamp(msg)).calendar(null, {
15 sameDay: '[Today]',
16 lastDay: '[Yesterday]',
17 lastWeek: '[Last] dddd'
18 })
19 }
20}
21

Built with git-ssb-web