Revision d87a18b7

View differences:

src/sunstone/public/app/app.js
294 294
      }
295 295
    }
296 296

  
297
    jQuery.extend( jQuery.fn.dataTableExt.oSort, {
298
      "date-euro-pre": function ( a ) {
299
          var x;
300

  
301
          if ( $.trim(a) !== '' ) {
302
              var frDatea = $.trim(a).split(' ');
303
              var frTimea = (undefined != frDatea[1]) ? frDatea[1].split(':') : [00,00,00];
304
              var frDatea2 = frDatea[0].split('/');
305
              x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + ((undefined != frTimea[2]) ? frTimea[2] : 0)) * 1;
306
          }
307
          else {
308
              x = Infinity;
309
          }
310

  
311
          return x;
312
      },
313

  
314
      "date-euro-asc": function ( a, b ) {
315
          return a - b;
316
      },
317

  
318
      "date-euro-desc": function ( a, b ) {
319
          return b - a;
320
      }
321

  
322
    });
323

  
297 324
    //source https://cdn.datatables.net/plug-ins/1.10.12/type-detection/ip-address.js (modified)
298 325
    jQuery.fn.dataTableExt.aTypes.unshift(
299 326
      function ( sData )
src/sunstone/public/app/tabs/marketplaceapps-tab/datatable.js
75 75
          {"sWidth": "35px", "aTargets": [0]},
76 76
          {"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)},
77 77
          {"bVisible": false, "aTargets": ['_all']},
78
          {"sType": "file-size", "aTargets": [ 6 ] }
78
          {"sType": "file-size", "aTargets": [ 6 ]},
79
          {"sType": "date-euro", "aTargets": [ 9 ]}
79 80
      ]
80 81
    }
81 82

  
......
150 151
        Humanize.sizeFromMB(element.SIZE),
151 152
        state,
152 153
        OpenNebulaMarketPlaceApp.typeStr(element.TYPE),
153
        Humanize.prettyTime(element.REGTIME),
154
        Humanize.prettyTimeDatatable(element.REGTIME),
154 155
        element.MARKETPLACE,
155 156
        zone,
156 157
        (LabelsUtils.labelsStr(element[TEMPLATE_ATTR])||''),
src/sunstone/public/app/tabs/templates-tab/datatable-common.js
58 58
          {"bSortable": false, "aTargets": ["check"]},
59 59
          {"sWidth": "35px", "aTargets": [0]},
60 60
          {"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(tabId)},
61
          {"bVisible": false, "aTargets": ['_all']}
61
          {"bVisible": false, "aTargets": ['_all']},
62
          {"sType": "date-euro", "aTargets": [ 5 ]}
62 63
      ]
63 64
    }
64 65

  
......
118 119
        element.NAME,
119 120
        element.UNAME,
120 121
        element.GNAME,
121
        Humanize.prettyTime(element.REGTIME),
122
        Humanize.prettyTimeDatatable(element.REGTIME),
122 123
        (LabelsUtils.labelsStr(element[TEMPLATE_ATTR])||''),
123 124
        btoa(unescape(encodeURIComponent(JSON.stringify(search))))
124 125
    ];
src/sunstone/public/app/utils/humanize.js
32 32
    'prettyTime': _prettyTime,
33 33
    'prettyTimeAxis': _prettyTimeAxis,
34 34
    'prettyPrintJSON': _prettyPrintJSON,
35
    'prettyTimeAgo': _format_date
35
    'prettyTimeAgo': _format_date,
36
    'prettyTimeDatatable': _prettyTimeDatatable
36 37
  }
37 38

  
38 39
  /*
......
240 241
    return str;
241 242
  }
242 243

  
244
  function _prettyTimeDatatable(seconds) {
245
    var d = new Date();
246
    d.setTime(seconds * 1000);
247

  
248
    var secs = _pad(d.getSeconds(), 2);
249
    var hour = _pad(d.getHours(), 2);
250
    var mins = _pad(d.getMinutes(), 2);
251
    var day = _pad(d.getDate(), 2);
252
    var month = _pad(d.getMonth() + 1, 2); //getMonths returns 0-11
253
    var year = d.getFullYear();
254

  
255
    return day + "/" + month + "/" + year + " " + hour + ":" + mins + ":" + secs;
256
  }
257

  
243 258
  function _format_date(unix_timestamp) {
244 259
    var difference_in_seconds = (Math.round((new Date()).getTime() / 1000)) - unix_timestamp,
245 260
        current_date = new Date(unix_timestamp * 1000), minutes, hours;

Also available in: Unified diff