git ssb

16+

Dominic / patchbay



Tree: 33dbf75c73b0fb716af94766e08f4dd2fd3443d5

Files: 33dbf75c73b0fb716af94766e08f4dd2fd3443d5 / modules / 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