Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp/WebApp/helper.js @ 12419

Last change on this file since 12419 was 12419, checked in by dglaser, 9 years ago

#2388: Added WebApp and WebApp.Status plugin

File size: 1.1 KB
Line 
1var isDefined = function(variable) {
2    return !(variable === undefined || variable === null);
3};
4
5function zeropad(n) { return ("0" + n).slice(-2); }
6
7Number.prototype.zeropad = function (n) {
8    return (new Array(n + 1).join("0") + this).slice(-n);
9};
10
11var ConvertDate = function (date) {
12    var day = date.getDate().zeropad(2);
13    var month = (1 + date.getMonth()).zeropad(2);
14    var year = date.getFullYear();
15    var hour = (date.getHours() - 2).zeropad(2);
16    var minute = date.getMinutes().zeropad(2);
17    var second = date.getSeconds().zeropad(2);
18    return year + '-' + month + '-' + day + 'T' + hour + ':' + minute + ':' + second + '.000Z';
19};
20
21var ConvertFromDate = function (date) {
22    var day = date.getDate().zeropad(2);     
23    var month = (1 + date.getMonth()).zeropad(2);
24    var year = date.getFullYear();
25    return year + '-' + month + '-' + day + 'T00:00:00.000Z';
26};
27
28var ConvertToDate = function (date) {
29    var day = date.getDate().zeropad(2);
30    var month = (1 + date.getMonth()).zeropad(2);
31    var year = date.getFullYear();
32    return year + '-' + month + '-' + day + 'T23:59:59.000Z';
33};
Note: See TracBrowser for help on using the repository browser.