Solved

Day time not updating properly !

Posted on 2002-04-22
5
136 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Simple PHP Upload Script 11 2,686
website template 12 315
Read More links 12 336
Debug application start 2 272
For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
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 …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now