git ssb

16+

Dominic / patchbay



Tree: 6b7437f1d5284034579577ef86dec032a5d44367

Files: 6b7437f1d5284034579577ef86dec032a5d44367 / modules_basic / timestamp.js

655 bytesRaw
1var h = require('hyperscript')
2var _human = require('human-time')
3
4function human (date) {
5 var s =_human(date).split(' ')
6 return s[0] + (s[1] == 'month' ? 'M' : s[1][0])
7}
8
9function updateTimestampEl(el) {
10 el.firstChild.nodeValue = human(new Date(el.timestamp))
11 return el
12}
13
14setInterval(function () {
15 var els = [].slice.call(document.querySelectorAll('.timestamp'))
16 els.forEach(updateTimestampEl)
17}, 60e3)
18
19exports.message_meta = function (msg) {
20 var d = new Date(msg.value.timestamp)
21 return updateTimestampEl(h('a.enter.timestamp', {
22 href: '#'+msg.key,
23 timestamp: msg.value.timestamp,
24 title: _human(d) + '\n'+d
25 }, ''))
26}
27
28
29
30

Built with git-ssb-web