Сообщение от JSprog
|
нда...
чувствую с php вы не знакомы
|
Оказалось что это не так...
Теперь по теме:
После дня тра..ния мозга получилось вот что:
function isDaylightTime()
{
var rightNow = new Date();
var date1 = new Date(rightNow.getFullYear(), 0, 1, 0, 0, 0, 0);
var date2 = new Date(rightNow.getFullYear(), 6, 1, 0, 0, 0, 0);
var temp = date1.toGMTString();
var date3 = new Date(temp.substring(0, temp.lastIndexOf(' ')-1));
var temp = date2.toGMTString();
var date4 = new Date(temp.substring(0, temp.lastIndexOf(' ')-1));
var hoursDiffStdTime = (date1 - date3) / (1000 * 60 * 60);
var hoursDiffDaylightTime = (date2 - date4) / (1000 * 60 * 60);
if (hoursDiffDaylightTime == hoursDiffStdTime)
{
return false;
}
else
{
//is present summer time
return true;
}
}
function getTimeInsteadOfTimezone(intHH, intMM, intGMT)
{
var result = '';
if(isDaylightTime()) { intGMT += 1; }
var strHH = intHH;
var strMM = intMM;
if (intHH < 10) { strHH = '0' + intHH; }
if (intMM < 10) { strMM = '0' + intMM; }
var objCurrentDate = new Date();
var arWeekDays = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
var arMonth = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var strDayOfWeek = arWeekDays[objCurrentDate.getDay()];
var strMonth = arMonth[objCurrentDate.getMonth()];
var intDay = objCurrentDate.getDate();
var intYear = objCurrentDate.getFullYear();
var strSeconds = '00'
var strGMT = intGMT;
if (intGMT >= 0) { strGMT = '+' + intGMT; }
var objExpectedDate = strDayOfWeek + ' ' + strMonth + ' ' + intDay + ' ' + intYear + ' ' + strHH + ':' + strMM + ':' + strSeconds + ' GMT' + strGMT;
var intExpectedDate = Date.parse(objExpectedDate);
var intExpectedHH = new Date(intExpectedDate).getHours();
var intExpectedMM = new Date(intExpectedDate).getMinutes();
var strExpectedHH = intExpectedHH;
var strExpectedMM = intExpectedMM;
if (intExpectedHH < 10) { strExpectedHH = '0' + intExpectedHH; }
if (strExpectedMM < 10) { strExpectedMM = '0' + intExpectedMM; }
result = strExpectedHH + ':' + strExpectedMM;
return result;
}