-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimeFormat.js
More file actions
44 lines (36 loc) · 1.42 KB
/
timeFormat.js
File metadata and controls
44 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************
License: MIT
Authors: Lukas Michalski, Benjamin Zeller, Thorsten Schwalb
************************************************************************ */
qx.Class.define("pms.timeFormat",{
statics:
{
/******************************************************************************
* FUNCTION: displayFormat
******************************************************************************/
displayFormat: 'd.m.Y - H:i:s',
/******************************************************************************
* FUNCTION: format
******************************************************************************/
format: function(timestamp) {
var d = new Date(timestamp * 1000);
var output = this.displayFormat;
output = output.replace(/d/g, this.padZero(d.getDate()))
.replace(/m/g, this.padZero(d.getMonth()))
.replace(/Y/g, d.getFullYear())
.replace(/H/g, this.padZero(d.getHours()))
.replace(/i/g, this.padZero(d.getMinutes()))
.replace(/s/g, this.padZero(d.getSeconds()));
return output;
},
/******************************************************************************
* FUNCTION: padZero
******************************************************************************/
padZero: function(number) {
if (number < 10) {
return "0" + number.toString();
}
return number;
}
}
});