Files: aabb27408791b10bbb6e9ba87c00240141ddec4a / lib / message / html / timestamp.js
591 bytesRaw
1 | const h = require('mutant/h') |
2 | const moment = require('moment-timezone') |
3 | const getTimestamp = require('../../get-timestamp') |
4 | const getRoot = require('../sync/root') |
5 | |
6 | module.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