-
Notifications
You must be signed in to change notification settings - Fork 0
/
trivantis-timedate.js
50 lines (46 loc) · 1.25 KB
/
trivantis-timedate.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
49
50
/**************************************************
Trivantis (http://www.trivantis.com)
**************************************************/
//functions for realtime date/time
function FormatDS( now ) {
return now.toLocaleDateString()
}
function FormatTS( now ) {
var time = now.toLocaleTimeString()
if (time.length>3) {
idx=time.lastIndexOf(':')
if (idx>=0) {
var timenosec = time.substring(0,idx)
if (time.length>=idx+3)
timenosec = timenosec + time.substring(idx+3,time.length)
time = timenosec
}
}
idx=time.lastIndexOf(' ')
if (idx>0 && idx==time.length-4)
time = time.substring(0,time.length-4)
return time;
}
function FormatETS( eT ) {
var mills = eT % 1000
eT -= mills
eT /= 1000
var secs = eT % 60
eT -= secs
eT /= 60
var mins = eT % 60
eT -= mins
eT /= 60
var hours = eT
if( hours < 10 ) hours = "0" + hours
if( mins < 10 ) mins = "0" + mins
if( secs < 10 ) secs = "0" + secs
return hours + ':' + mins + ':' + secs
}
function CalcTD( f, val ) {
var tV = 0
if( f == 1 ) tV += 24 * 60 * 60 * 1000 * val
else if( f == 2 ) tV += 60 * 1000 * val
else if( f == 4 ) tV += 1000 * val
return tV
}