timeago.js 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +8 -8
- package/.travis.yml +2 -2
- package/LICENSE +20 -20
- package/README.md +189 -189
- package/README_zh.md +172 -172
- package/bower.json +21 -21
- package/demo/index.html +121 -0
- package/demo/index.js +25 -17
- package/dist/timeago.js +261 -258
- package/dist/timeago.locales.min.js +1 -1
- package/dist/timeago.min.js +1 -1
- package/gulpfile.js +13 -13
- package/index.html +185 -182
- package/locales/ar.js +26 -26
- package/locales/be.js +51 -51
- package/locales/bg.js +18 -18
- package/locales/ca.js +18 -18
- package/locales/da.js +18 -18
- package/locales/de.js +18 -18
- package/locales/el.js +18 -18
- package/locales/en.js +18 -18
- package/locales/en_short.js +17 -17
- package/locales/es.js +17 -17
- package/locales/eu.js +18 -18
- package/locales/fa.js +18 -0
- package/locales/fi.js +18 -18
- package/locales/fr.js +17 -17
- package/locales/he.js +18 -18
- package/locales/hu.js +18 -18
- package/locales/in_ID.js +18 -18
- package/locales/it.js +18 -18
- package/locales/ja.js +18 -18
- package/locales/ko.js +17 -17
- package/locales/locales.js +6 -6
- package/locales/ml.js +18 -18
- package/locales/my.js +18 -0
- package/locales/nl.js +18 -18
- package/locales/pl.js +34 -34
- package/locales/pt_BR.js +18 -18
- package/locales/ro.js +29 -29
- package/locales/ru.js +51 -51
- package/locales/sv.js +18 -18
- package/locales/ta.js +17 -17
- package/locales/th.js +18 -18
- package/locales/tr.js +18 -18
- package/locales/uk.js +40 -40
- package/locales/vi.js +18 -18
- package/locales/zh_CN.js +17 -17
- package/locales/zh_TW.js +17 -17
- package/package.json +49 -49
- package/src/timeago.js +261 -258
- package/src/timeago.locales.js +12 -12
- package/tests/locales/ar.js +66 -66
- package/tests/locales/be.js +63 -63
- package/tests/locales/bg.js +63 -63
- package/tests/locales/ca.js +64 -64
- package/tests/locales/en.js +62 -62
- package/tests/locales/en_short.js +62 -62
- package/tests/locales/eu.js +63 -63
- package/tests/locales/fa.js +63 -0
- package/tests/locales/fi.js +43 -43
- package/tests/locales/he.js +62 -62
- package/tests/locales/in_BG.js +63 -63
- package/tests/locales/in_HI.js +63 -63
- package/tests/locales/in_ID.js +62 -62
- package/tests/locales/ja.js +62 -62
- package/tests/locales/ko.js +62 -62
- package/tests/locales/my.js +63 -0
- package/tests/locales/pl.js +91 -91
- package/tests/locales/ro.js +61 -61
- package/tests/locales/ru.js +63 -63
- package/tests/locales/ta.js +62 -62
- package/tests/locales/tr.js +63 -63
- package/tests/locales/uk.js +63 -63
- package/tests/locales/vi.js +63 -63
- package/tests/locales/zh_CN.js +62 -62
- package/tests/locales_test.js +51 -51
- package/tests/test-builder.js +247 -247
- package/tests/test.js +83 -83
- package/tests/test_dev.js +44 -44
- package/tests/test_ts.ts +6 -6
- package/timeago.d.ts +14 -14
- package/webpack.config.js +10 -10
package/tests/test_dev.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const test = require('tape');
|
|
4
|
-
const timeago = require('..');
|
|
5
|
-
|
|
6
|
-
test('timeago.js next interval show be tested', t => {
|
|
7
|
-
t.true(timeago().nextInterval(0.134), 1);
|
|
8
|
-
t.true(timeago().nextInterval(8.1), 1);
|
|
9
|
-
t.true(timeago().nextInterval(59.3), 1);
|
|
10
|
-
|
|
11
|
-
t.true(timeago().nextInterval(70.13), 50);
|
|
12
|
-
|
|
13
|
-
t.true(timeago().nextInterval(60 * 3 + 10.01), 50);
|
|
14
|
-
// 10 hours
|
|
15
|
-
t.true(timeago().nextInterval(3600 * 10 + 100.01), 3500);
|
|
16
|
-
// 3 days
|
|
17
|
-
t.true(timeago().nextInterval(60 * 60 * 24 * 3 + 100.01), 3600 * 24 -100);
|
|
18
|
-
|
|
19
|
-
// 2 weeks
|
|
20
|
-
t.true(timeago().nextInterval(60 * 60 * 24 * 15 + 100.01), 3600 * 24 * 6 - 100);
|
|
21
|
-
|
|
22
|
-
// 10 years
|
|
23
|
-
t.true(timeago().nextInterval(3600 * 24 * 365 * 3 + 100.01), 3600 * 24 * 365 - 100);
|
|
24
|
-
|
|
25
|
-
////////////////////////////////////////
|
|
26
|
-
|
|
27
|
-
t.true(timeago().nextInterval(-0.134), 1);
|
|
28
|
-
t.true(timeago().nextInterval(-8.1), 1);
|
|
29
|
-
t.true(timeago().nextInterval(-59.3), 1);
|
|
30
|
-
|
|
31
|
-
t.true(timeago().nextInterval(-70.13), 50);
|
|
32
|
-
|
|
33
|
-
t.true(timeago().nextInterval(-60 * 3 + 10.01), 50);
|
|
34
|
-
// 10 hours
|
|
35
|
-
t.true(timeago().nextInterval(-3600 * 10 + 100.01), 3500);
|
|
36
|
-
// 3 days
|
|
37
|
-
t.true(timeago().nextInterval(-60 * 60 * 24 * 3 + 100.01), 3600 * 24 -100);
|
|
38
|
-
|
|
39
|
-
// 2 weeks
|
|
40
|
-
t.true(timeago().nextInterval(-60 * 60 * 24 * 15 + 100.01), 3600 * 24 * 6 - 100);
|
|
41
|
-
|
|
42
|
-
// 10 years
|
|
43
|
-
t.true(timeago().nextInterval(-3600 * 24 * 365 * 3 + 100.01), 3600 * 24 * 365 - 100);
|
|
44
|
-
t.end();
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const test = require('tape');
|
|
4
|
+
const timeago = require('..');
|
|
5
|
+
|
|
6
|
+
test('timeago.js next interval show be tested', t => {
|
|
7
|
+
t.true(timeago().nextInterval(0.134), 1);
|
|
8
|
+
t.true(timeago().nextInterval(8.1), 1);
|
|
9
|
+
t.true(timeago().nextInterval(59.3), 1);
|
|
10
|
+
|
|
11
|
+
t.true(timeago().nextInterval(70.13), 50);
|
|
12
|
+
|
|
13
|
+
t.true(timeago().nextInterval(60 * 3 + 10.01), 50);
|
|
14
|
+
// 10 hours
|
|
15
|
+
t.true(timeago().nextInterval(3600 * 10 + 100.01), 3500);
|
|
16
|
+
// 3 days
|
|
17
|
+
t.true(timeago().nextInterval(60 * 60 * 24 * 3 + 100.01), 3600 * 24 -100);
|
|
18
|
+
|
|
19
|
+
// 2 weeks
|
|
20
|
+
t.true(timeago().nextInterval(60 * 60 * 24 * 15 + 100.01), 3600 * 24 * 6 - 100);
|
|
21
|
+
|
|
22
|
+
// 10 years
|
|
23
|
+
t.true(timeago().nextInterval(3600 * 24 * 365 * 3 + 100.01), 3600 * 24 * 365 - 100);
|
|
24
|
+
|
|
25
|
+
////////////////////////////////////////
|
|
26
|
+
|
|
27
|
+
t.true(timeago().nextInterval(-0.134), 1);
|
|
28
|
+
t.true(timeago().nextInterval(-8.1), 1);
|
|
29
|
+
t.true(timeago().nextInterval(-59.3), 1);
|
|
30
|
+
|
|
31
|
+
t.true(timeago().nextInterval(-70.13), 50);
|
|
32
|
+
|
|
33
|
+
t.true(timeago().nextInterval(-60 * 3 + 10.01), 50);
|
|
34
|
+
// 10 hours
|
|
35
|
+
t.true(timeago().nextInterval(-3600 * 10 + 100.01), 3500);
|
|
36
|
+
// 3 days
|
|
37
|
+
t.true(timeago().nextInterval(-60 * 60 * 24 * 3 + 100.01), 3600 * 24 -100);
|
|
38
|
+
|
|
39
|
+
// 2 weeks
|
|
40
|
+
t.true(timeago().nextInterval(-60 * 60 * 24 * 15 + 100.01), 3600 * 24 * 6 - 100);
|
|
41
|
+
|
|
42
|
+
// 10 years
|
|
43
|
+
t.true(timeago().nextInterval(-3600 * 24 * 365 * 3 + 100.01), 3600 * 24 * 365 - 100);
|
|
44
|
+
t.end();
|
|
45
45
|
});
|
package/tests/test_ts.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// just test typescript can be compiled and ran.
|
|
2
|
-
// TODO: if trace or error, travis-ci will error
|
|
3
|
-
|
|
4
|
-
console.log('run typescript.')
|
|
5
|
-
import timeago from '..'
|
|
6
|
-
const timeagoInstance = timeago()
|
|
1
|
+
// just test typescript can be compiled and ran.
|
|
2
|
+
// TODO: if trace or error, travis-ci will error
|
|
3
|
+
|
|
4
|
+
console.log('run typescript.')
|
|
5
|
+
import timeago from '..'
|
|
6
|
+
const timeagoInstance = timeago()
|
|
7
7
|
console.log(timeagoInstance.format('01-01-2017'))
|
package/timeago.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/// <reference types="jquery" />
|
|
2
|
-
type TDate = Date | string | number;
|
|
3
|
-
export interface TimeAgoInterface {
|
|
4
|
-
format(date: TDate, locale?: string): string;
|
|
5
|
-
render<T>(nodes: Node | NodeList | JQuery, locale?: string): void;
|
|
6
|
-
setLocale(locale: string): void;
|
|
7
|
-
}
|
|
8
|
-
export interface TimeagoFactory {
|
|
9
|
-
(): TimeAgoInterface;
|
|
10
|
-
(nowDate: TDate, defaultLocale?: string): TimeAgoInterface;
|
|
11
|
-
cancel(node?: Node | JQuery): void;
|
|
12
|
-
register(locale: string, localeFunc: Function): void;
|
|
13
|
-
}
|
|
14
|
-
declare let timeagoFactory: TimeagoFactory;
|
|
1
|
+
/// <reference types="jquery" />
|
|
2
|
+
type TDate = Date | string | number;
|
|
3
|
+
export interface TimeAgoInterface {
|
|
4
|
+
format(date: TDate, locale?: string): string;
|
|
5
|
+
render<T>(nodes: Node | NodeList | JQuery, locale?: string): void;
|
|
6
|
+
setLocale(locale: string): void;
|
|
7
|
+
}
|
|
8
|
+
export interface TimeagoFactory {
|
|
9
|
+
(): TimeAgoInterface;
|
|
10
|
+
(nowDate: TDate, defaultLocale?: string): TimeAgoInterface;
|
|
11
|
+
cancel(node?: Node | JQuery): void;
|
|
12
|
+
register(locale: string, localeFunc: Function): void;
|
|
13
|
+
}
|
|
14
|
+
declare let timeagoFactory: TimeagoFactory;
|
|
15
15
|
export default timeagoFactory;
|
package/webpack.config.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var webpack = require('webpack');
|
|
2
|
-
var uglifyJsPlugin = new webpack.optimize.UglifyJsPlugin({
|
|
3
|
-
output: {comments: false},
|
|
4
|
-
compress: {warnings: false}
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
entry: './src/timeago.locales.js',
|
|
9
|
-
output: {filename: './dist/timeago.locales.min.js'},
|
|
10
|
-
plugins: [uglifyJsPlugin]
|
|
1
|
+
var webpack = require('webpack');
|
|
2
|
+
var uglifyJsPlugin = new webpack.optimize.UglifyJsPlugin({
|
|
3
|
+
output: {comments: false},
|
|
4
|
+
compress: {warnings: false}
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
entry: './src/timeago.locales.js',
|
|
9
|
+
output: {filename: './dist/timeago.locales.min.js'},
|
|
10
|
+
plugins: [uglifyJsPlugin]
|
|
11
11
|
};
|