Repository navigation
Expand file tree
/
Copy pathuniDateTime_.js
More file actions
40 lines (39 loc) · 1.43 KB
/
Copy pathuniDateTime_.js
File metadata and controls
40 lines (39 loc) · 1.43 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
//~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`
function uniDateTime_(InDate,TimeFormats,logs)
{
var InDate = typeof InDate !== 'undefined' ? InDate : ""
var TimeFormats = typeof TimeFormats !== 'undefined' ? TimeFormats : ""
var logs = typeof logs !== 'undefined' ? logs : "";
if (InDate == "")
{
if (TimeFormats == "")
{
return new Date();
}
else
{
var result = Utilities.formatDate(new Date(), "PST", TimeFormats);
return result;
}
}
if (Object.prototype.toString.call(InDate) === "[object Date]" )
{ //date it is a date object
if(logs=="x"){Logger.log('UniDate:1-' + InDate);}
if ( isNaN( InDate.getTime() ) )
{ // d.valueOf() could also work
if(logs=="x"){Logger.log('UniDate:2-' + InDate);} // date is not valid
return;
}
else
{
var result = Utilities.formatDate(new Date(InDate), "PST", TimeFormats);
return result;
}
}
else
{
if(logs=="x"){Logger.log('UniDate:3-' + InDate);}
return;
}
}
//~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`~,~`