Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Services.WebApp/3.3/WebApp/helper.js @ 12546

Last change on this file since 12546 was 12428, checked in by ascheibe, 9 years ago

#2394 added web app and status page to trunk

File size: 1.6 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};
34
35
36var CSharpDateToString = function (datetime) {
37    var date = new Date(Date.parse(datetime));
38    var day = date.getDate().zeropad(2);
39    var month = (1 + date.getMonth()).zeropad(2);
40    var year = date.getFullYear();
41    var hour = date.getHours().zeropad(2);
42    var minute = date.getMinutes().zeropad(2);
43    var second = date.getSeconds().zeropad(2);
44    return day + '.' + month + '.' + year + ' ' + hour + ':' + minute + ':' + second;
45};
Note: See TracBrowser for help on using the repository browser.