-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.js
48 lines (44 loc) · 1.36 KB
/
functions.js
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
45
46
47
48
module.exports = {
parseDate: function(date, type, points) {
var yyyy = date.getFullYear().toString();
var MM = (date.getMonth() + 1).toString().padStart(2,'0');
var dd = date.getDate().toString().padStart(2,'0');
var hh = date.getHours().toString().padStart(2,'0');
var mm = date.getMinutes().toString().padStart(2,'0');
var ss = date.getSeconds().toString().padStart(2,'0');
if (type === 'date')
{
if (points)
{
return yyyy+'.'+MM+'.'+dd;
}
else
{
return yyyy+MM+dd;
}
}
else if (type === 'time')
{
return hh + ':' + mm + ':' + ss + '.000'
}
else
{
return yyyy+MM+dd+hh+mm+ss;
}
},
generateDNI: function(dni) {
const cadena="TRWAGMYFPDXBNJZSQVHLCKET";
var posicion = dni%23;
var letra = cadena.substring(posicion,posicion+1);
return dni+letra;
},
generateId: function(length) {
var result = '';
var characters = '0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
}