-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.js
28 lines (23 loc) · 981 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var ta = require('./timeago.js')
console.log(
ta.ago(new Date() - 1000), ta.ago(new Date() - 1000) === '1 second ago',
ta.ago(new Date() - 60000 * 180), ta.ago(new Date() - 60000 * 180) === '3 hours ago',
new Date(1), ta.ago(new Date(1)), ta.ago(new Date(1)) === '47 years ago'
);
console.log(
ta.ago(new Date() - 1000, true), ta.ago(new Date() - 1000, true) === '1s',
ta.ago(new Date() - 60000 * 180, true), ta.ago(new Date() - 60000 * 180, true) === '3h',
new Date(1), ta.ago(new Date(1), true), ta.ago(new Date(1), true) === '47y'
);
console.log(
'Today is ' + ta.today()
);
console.log(
ta.timefriendly('1 hour'), ta.timefriendly('1 hour') === 1000 * 60 * 60,
ta.timefriendly('2 days'), ta.timefriendly('2 days') === 1000 * 60 * 60 * 48,
ta.timefriendly('2 weeks'), ta.timefriendly('2 weeks') === 1000 * 60 * 60 * 24 * 14
);
var i = 0,
text = '';
while (i++ < 600) text += 'text ';
console.log(text.length, 'chars, min to read', ta.mintoread(text));