Page 1 of 1

[Request] Stardate on forum [Solved]

PostPosted: Fri Aug 18, 2006 10:34 am
Author: krillmeed
I apologise if this is in the wrong forum :xo:

PostPosted: Fri Aug 18, 2006 11:10 am
Author: krillmeed
Point of note here, I do have a JScript Script File that does this, and i have permission from the author to use it, but i upload it to the template, then as i did on my main website that is html of course, i put this in the overall header: <script></script>
<SCRIPT>TodayAsStarDate();</SCRIPT> and nothing. What am i doing wrong?

Re: [Request] Stardate on forum

PostPosted: Sun Aug 20, 2006 3:19 am
Author: found it
Hi

Where is the file Stardate.js located in your site...?

As this may not have the path correctly set up to it....with out more info it is kinda hard to see otherwise...

:mrgreen:

PostPosted: Sun Aug 20, 2006 4:08 am
Author: krillmeed
I place the js file in the template folder, and tried to enter the code in the overall header

Re: [Request] Stardate on forum

PostPosted: Sun Aug 20, 2006 4:12 am
Author: krillmeed
This is what the js script looks like:
Code: Select all
 // This code was developed by Keith Scott for Adge Cutler - [url=http]http://www.lcars.org.uk//[/url] Feel free to use this code, however no warranty is provided as to the accuracy// of the coding.// If you choose to use this, please include a link back to [url=http://www.lcars.org.uk]http://www.lcars.org.uk[/url] on your site.// Thank you.   Keith Scott  07/09/2004  var DaysIntoYear = 0;var DaysInYear = 0;var Year = 0;var Month = 0;var Day = 0;var Hour = 0;var Minute = 0;var StarDate = "";var MonthDays = new Array();var Data = "";  MonthDays[1] = 31;MonthDays[2] = 28;MonthDays[3] = 31;MonthDays[4] = 30;MonthDays[5] = 31;MonthDays[6] = 30;MonthDays[7] = 31;MonthDays[8] = 31;MonthDays[9] = 30;MonthDays[10] = 31;MonthDays[11] = 30;MonthDays[12] = 31;  function Calculate() {     if ( Data == "" ) Data = document.getElementById('Data');     DaysIntoYear = 0;     Year = 0;     Month = 0;     Day = 0;     Hour = 0;     Minute = 0;     StarDate = "";     var StarDatePattern = /^-?d{4,7}.d{0,4}$/     var DatePattern = /dd/dd/dddd$/     var DateTimePattern = /dd/dd/ddddsddSdd$/     var DateValue = Data.value.substr(0,10);     var TimeValue = Data.value.substr(11,5);     if ( Data.value.match(DateTimePattern) ) {         Check_Date(DateValue);         Check_Time(TimeValue);         if ( StarDate != "Invalid!" ) CalculateStarDate();         return;     }         if ( Data.value.match(DatePattern) ) {         Check_Date(DateValue);         if ( StarDate != "Invalid!" ) CalculateStarDate();         return;     }       if ( Data.value.match(StarDatePattern) ) {         CalculateRealDate(Data.value);         return;     }       alert("Invalid date format!");}  function Check_Date(DateText){       var err = 0;     var leap = 0;     Year = DateText.substr(6,4);     Month = DateText.substr(3,2);     Day = DateText.substr(0,2);     if (Year == 0) {         err = 20;     }     if ((Month <1> 12)) {         err = 21;     }     if ((Day <1> 32)) {         err = 22;     }     if ((Year % 4 == 0) || (Year % 100 == 0) || (Year % 400 == 0)) {         leap = 1;         MonthDays[2] = 29;     }     else {         leap = 0;         MonthDays[2] = 28;     }     if ((Month == 2) && (leap == 1) && (Day > 29)) {         err = 23;     }     if ((Month == 2) && (leap != 1) && (Day > 28)) {         err = 24;     }     if ((Day > 30) && ((Month == "04") || (Month == "06") || (Month == "09") || (Month == "11"))) {         err = 26;     }     if (err == 0) {         for ( i=1;i<Month> 23 || Minute > 59 ) DateType = "";}  function CalculateStarDate() {       var FirstPart = "";     var MinutesPart = 0;     var HoursPart = 0;     var DaysPart = 0;     var InterimDate = "";     FirstPart = Year - 2323;     MinutesPart = Minute / 60;     HoursPart = ( ( Hour * 1 )+MinutesPart  ) / 24;     DaysPart = ( parseInt(DaysIntoYear) + HoursPart ) / DaysInYear;     DaysPart = DaysPart * 1000;     InterimDate = FirstPart+""+DaysPart;     StarDate = parseInt(InterimDate*10000)/10000;     document.getElementById('Result').innerHTML = "Stardate: " + StarDate;}  function CalculateRealDate(DateText) {       var DatePart = "";     var MinutesPart = 0;     var HoursPart = 0;     var DaysPart = 0;     var MonthCount = 0;     DatePart = DateText.substring(DateText.indexOf(".")-3,DateText.length+1);     YearPart = DateText.substr(0,DateText.indexOf(".")-3);     Year = 2323 + parseInt(YearPart);     if ((Year % 4 == 0) || (Year % 100 == 0) || (Year % 400 == 0)) {         MonthDays[2] = 29;         DaysInYear = 366;     }     else {         MonthDays[2] = 28;         DaysInYear = 365;     }     DatePart = DatePart/1000;     DaysIntoYear = parseInt(DatePart*DaysInYear);     Hours = parseInt(((DatePart*DaysInYear)-DaysIntoYear)*24);     Minutes = parseInt(((((DatePart*DaysInYear)-DaysIntoYear)*24)-Hours)*60);     for (i=1;i<13;i++) {         if ( DaysIntoYear < MonthDays[i] ) {             i = 13;         }         else {             DaysIntoYear = ( DaysIntoYear - MonthDays[i]);             MonthCount++;         }     }     DaysIntoYear++;     MonthCount++;     Day = "0"+DaysIntoYear;     Day = Day.substr(Day.length-2,2);     Month = "0"+MonthCount;     Month = Month.substr(Month.length-2,2);     Hour = "0"+Hours;     Hour = Hour.substr(Hour.length-2,2);     Minute = "0"+Minutes;     Minute = Minute.substr(Minute.length-2,2);     DateText = Day+"/"+Month+"/"+Year+" "+Hour+":"+Minute;     document.getElementById('Result').innerHTML = "Calendar date: " + DateText;}  function TodayAsStarDate() {       var weekDayName = new Array ("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")     var curDate = new Date();     Day = "0"+curDate.getDate();     Day = Day.substr(Day.length-2,2);     Month = "0"+(curDate.getMonth()+1);     Month = Month.substr(Month.length-2,2);     Year = curDate.getYear();     if (Year < 2000) Year += 1900; //for Netscape     Hour = "0"+curDate.getHours();     Hour = Hour.substr(Hour.length-2,2);     Minute = "0"+curDate.getMinutes();     Minute = Minute.substr(Minute.length-2,2);     var Weekday = weekDayName[curDate.getDay()];     Today = Day+"/"+Month+"/"+Year+" "+Hour+":"+Minute;     Check_Date(Today);     var FirstPart = "";     var MinutesPart = 0;     var HoursPart = 0;     var DaysPart = 0;     var InterimDate = "";     FirstPart = Year - 2323;     MinutesPart = Minute / 60;     HoursPart = ( parseInt(Hour)+MinutesPart  ) / 24;     DaysPart = ( parseInt(DaysIntoYear) + HoursPart ) / DaysInYear;     DaysPart = DaysPart * 1000;     InterimDate = FirstPart+""+DaysPart;     StarDate = parseInt(InterimDate*10000)/10000;     document.write("<font>Today is <I>" + Weekday + " " + Day+"/"+Month+"/"+Year+"</I> Time <I>"+Hour+":"+Minute + "</I><BR>Stardate: <I>" + StarDate + "</I></FONT>");}    

Re: [Request] Stardate on forum

PostPosted: Sun Aug 20, 2006 4:53 am
Author: found it
hi

If you have placed the js file in your template folder you need to edit the code in your overall_header.tpl file so it follows the correct path...

change

Code: Select all
<script></script><SCRIPT>TodayAsStarDate();</SCRIPT>


to

Code: Select all
<script></script><SCRIPT>TodayAsStarDate();</SCRIPT>


let me know...

:mrgreen:

PostPosted: Sun Aug 20, 2006 5:00 am
Author: krillmeed
Thanks i will give it ago, my forum is down at the moment because the yahoo database server is down. It has been over 24 hours since i emailed them last, they are useless. I will let you know how this works. Thanks for your help <img>

PostPosted: Tue Aug 22, 2006 11:29 am
Author: krillmeed
Sir you are a star, works like a dream, i have added it into the index body of each template, apart from the stardate, we also have GMT time which comes in handy for our weekly chat sessions, now no one has to convert. By the way if anyone want this little addon feel free to email me. Looks rather good <img>

Re: [Request] Stardate on forum [Solved]

PostPosted: Tue Aug 22, 2006 12:57 pm
Author: found it
no problem happy to help...

:mrgreen: