git ssb

16+

Dominic / patchbay



Tree: 9275fb674485193b85f4e7852ab00e1908d0c514

Files: 9275fb674485193b85f4e7852ab00e1908d0c514 / 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