Solved

Day time not updating properly !

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Dreamweaver CS6 keyboard shortcut 8 1,058
Issue when emailing and there is a space 7 403
Lock Form Controls 3 309
adobe product that creates checks to sales people for bringing sales 5 392
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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