6 changed files with 92 additions and 78 deletions
-
10app/helpers/DateHelper.php
-
79app/helpers/TimezoneHelper.php
-
7app/widgets/AdminMain/AdminMain.php
-
65app/widgets/AdminMain/admin.js
-
4app/widgets/AdminMain/adminmain.tpl
-
5bootstrap.php
@ -1,42 +1,43 @@ |
|||
var tz_list; |
|||
var original = true; |
|||
var operators = { |
|||
'+': function(a, b) { return a + b }, |
|||
'-': function(a, b) { return a - b }, |
|||
}; |
|||
|
|||
function update(elt){ |
|||
original = false; |
|||
if (elt.selectedIndex == -1) |
|||
return null; |
|||
text = elt.options[elt.selectedIndex].text; |
|||
h_m = text.split("(")[1].split(")")[0].split("."); |
|||
var today = new Date(); |
|||
if(h_m[0]<0){ |
|||
h_m[0] = h_m[0].substr(1); |
|||
today.setHours(today.getHours() - parseInt(h_m[0])); |
|||
today.setMinutes(today.getMinutes() - parseInt(h_m[1])); |
|||
} |
|||
else{ |
|||
today.setHours(today.getHours() + parseInt(h_m[0])); |
|||
today.setMinutes(today.getMinutes() + parseInt(h_m[1])); |
|||
} |
|||
return today; |
|||
//Get the offset from the selected option
|
|||
text = elt.options[elt.selectedIndex].text; |
|||
//Determine if it is a positive or negative offset
|
|||
sign = text.indexOf("+") > -1 ? "+" : "-"; |
|||
//Seperate hours and minutes and get the offset in ms
|
|||
h_m = text.split(sign)[1].split(")")[0].split(":"); |
|||
tzOffset = parseInt(h_m[0]) * 3600000 + parseInt(h_m[1]) * 60000; |
|||
//Get the offset between your computer and UTC
|
|||
pcOffset = new Date().getTimezoneOffset() * 60000; |
|||
|
|||
return new Date(operators[sign]((new Date().getTime() + pcOffset), tzOffset)); |
|||
} |
|||
movim_add_onload(function() |
|||
{ |
|||
tz_list = document.querySelector("#timezone"); |
|||
|
|||
tz_list.onchange = function(e){ |
|||
document.querySelector(".dTimezone").innerHTML = update(tz_list).toUTCString(); |
|||
} |
|||
setInterval( |
|||
function(){ |
|||
if(original){ |
|||
date = new Date(); |
|||
document.querySelector(".dTimezone").innerHTML = date.toUTCString(); |
|||
} |
|||
else{ |
|||
date = new Date(document.querySelector(".dTimezone").innerHTML); |
|||
date.setSeconds(date.getSeconds() + 1); |
|||
document.querySelector(".dTimezone").innerHTML = date.toUTCString(); |
|||
} |
|||
} |
|||
,1000); |
|||
tz_list = document.querySelector("#timezone"); |
|||
tz_list.onchange = function(e){ |
|||
newTime = update(tz_list); |
|||
formatDate(newTime); |
|||
} |
|||
setInterval( |
|||
function(){ //increment time each second
|
|||
date = new Date(document.querySelector(".dTimezone").innerHTML).getTime() + 1000; |
|||
date = formatDate(new Date(date)); |
|||
} |
|||
,1000); |
|||
|
|||
formatDate = function (newTime){ |
|||
h = newTime.getHours()<10 ? "0" + newTime.getHours() : newTime.getHours(); |
|||
m = newTime.getMinutes()<10 ? "0" + newTime.getMinutes() : newTime.getMinutes(); |
|||
s = newTime.getSeconds()<10 ? "0" + newTime.getSeconds() : newTime.getSeconds(); |
|||
document.querySelector(".dTimezone").innerHTML = newTime.toDateString() + " " + h+ ":" + m + ":" + s; |
|||
} |
|||
}); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue