[12962] | 1 | (function() {
|
---|
[12546] | 2 | var module = appMainPlugin.getAngularModule();
|
---|
| 3 | module.filter('kbToGB', function () {
|
---|
| 4 | return function (text, length, end) {
|
---|
| 5 | if (text == null || text == '') text = '0';
|
---|
| 6 | text = Math.round(parseInt(text, 10) / 1024);
|
---|
| 7 | return text;
|
---|
| 8 | };
|
---|
| 9 | });
|
---|
| 10 |
|
---|
| 11 | module.filter('toDate', function () {
|
---|
| 12 | return function (text, length, end) {
|
---|
| 13 | if (text == null || text == '' || text.length < 19)
|
---|
| 14 | return 'Invalid';
|
---|
| 15 | var day = text.slice(8, 10);
|
---|
| 16 | var month = text.slice(5, 7);
|
---|
| 17 | var year = text.slice(0, 4);
|
---|
| 18 | var hour = text.slice(11, 13);
|
---|
| 19 | var minute = text.slice(14, 16);
|
---|
| 20 | var second = text.slice(17, 19);
|
---|
| 21 | return day + '.' + month + '.' + year + ' ' + hour + ':' + minute + ':' + second;
|
---|
| 22 | };
|
---|
| 23 | });
|
---|
| 24 |
|
---|
| 25 | module.filter('toTimespan', function () {
|
---|
| 26 | return function (text, length, end) {
|
---|
| 27 | if (text == null || text == '') text = '0';
|
---|
| 28 | var d = Number(parseInt(text, 10));
|
---|
| 29 | var years = Math.floor(d / 31536000);
|
---|
| 30 | var days = Math.floor(d / 86400 % 365);
|
---|
| 31 | var h = Math.floor(d / 3600 % 24);
|
---|
| 32 | var m = Math.floor(d % 3600 / 60);
|
---|
| 33 | var s = Math.floor(d % 3600 % 60);
|
---|
| 34 | var timeStr = "";
|
---|
| 35 | if (years > 0) {
|
---|
| 36 | timeStr = years + "y ";
|
---|
| 37 | }
|
---|
| 38 | if (days > 0) {
|
---|
| 39 | timeStr = timeStr + days + "d ";
|
---|
| 40 | }
|
---|
| 41 | return timeStr + h.zeropad(2) + ":" + m.zeropad(2) + ":" + s.zeropad(2);
|
---|
| 42 | };
|
---|
| 43 | });
|
---|
| 44 | })(); |
---|