Solved

Day time not updating properly !

Posted on 2002-04-22
5
137 Views
Last Modified: 2011-04-14
My script did not adjust to the Time Change. How to modify it. I tried changinf the shorttime(X) value. Without any luck.

thanks fo ryou prompt help.

R.


<script language="javascript">
<!--
function writeInfo() {

        var curDate = new Date();
        fixDate(curDate);

        var la = "Los Angeles: <b>" + sortTime(-8) + "</b><br>"
        var paris = "Paris: <b>" + sortTime(1) + "</b><br>"    
       
        var str = "<b>" + getString(curDate) + "</b><br>";
       
        str = str + la + paris;
       
        tdClock.innerHTML = str;
       
        setTimeout("writeInfo()", 1000);
   }
   
   function sortTime(skew) {
       var dt = new Date();
       var def = dt.getTimezoneOffset()/60;
      var gmt = (dt.getHours() + def);    
      var ending = ":" + dt.getMinutes();

       if (skew < 0)
            var zoneTime =check24(((gmt + (24+skew)) >= 24) ? ((gmt + (24+skew)) - 24) : (gmt + (24+skew)));
        else
            var zoneTime =check24(((gmt + skew) > 24) ? ((gmt + skew) - 24) : (gmt + skew));
               
       zoneTime = (check12(zoneTime) + ending + IfAmPm(zoneTime))

       return zoneTime
   }
   
  function makeArray() {
    var args = makeArray.arguments;
    for (var i = 0; i < args.length; i++) {
      this[i] = args[i];
    }
    this.length = args.length;
  }
 
  function fixDate(date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
      date.setTime(date.getTime() - skew);
  }
 
  function getString(date) {
    var months = new makeArray("January", "February", "March",
                               "April",   "May",      "June",
                               "July",    "August",   "September",
                               "October", "November", "December");
    return months[date.getMonth()] + " " +
           date.getDate() + ", " +
           date.getFullYear();
  }
 
  function IfAmPm(hour) {
       if (hour > 12)
            return " PM"
       else
            return " AM"
  }
 
  function check24(hour) {
       return (hour >= 24) ? hour - 24 : hour;
  }
 
  function check12(hour) {
       return (hour >= 12) ? hour - 12 : hour;
  }

function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
 var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
   d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
 if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
 if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
0
Comment
Question by:rembrandt
  • 2
5 Comments
 

Author Comment

by:rembrandt
ID: 6962351
please help. Need the correction in few hours. I am sure it is not much but I'd appreciate your prompte assistance.

Thanks

r.
0
 
LVL 19

Accepted Solution

by:
webwoman earned 200 total points
ID: 6963633
You got it before -- change the difference between GMT and LA/Paris. THAT IS THE ONLY WAY TO FIX IT.

Do you get ANYTHING? Does it give an error?

You DO realize that this has to be on a page, has to have a div called tdClock, and without that it does NOTHING?

Because just the code you have there won't do anything, and if you don't have the right div it won't do anything -- and that has NOTHING to do with the time change.
0
 
LVL 19

Expert Comment

by:webwoman
ID: 6963643
And it is NOT 'shortime(xx)' it is
sortTime(xx) and if you don't use it EXACTLY that way, it WILL NOT WORK.

You must be PRECISE with javascript, it's not forgiving. Spelling count. Capitalization counts. Punctuation counts. EVERYTHING counts. sortTime is NOT the same as shortime, SortTime, sorttime, or any other variation.
0
 
LVL 5

Expert Comment

by:zenlion420
ID: 9834673
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: webwoman{6963633}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

zenlion420
EE Page Editor
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question