Solved

Day time not updating properly !

Posted on 2002-04-22
5
141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

615 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