Solved

Day time not updating properly !

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Record Button 3 233
website template 12 362
Coldfusion CFMESSAGEBOX Passing Variables 6 153
Adobe Dreamwever CS5.5 - mage sites help needed. 1 143
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 …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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