HELP!

Programmers Guild

Moderator: Andreas the Wise

Post Reply
User avatar
Daniel Farewell
Posts: 1104
Joined: Mon Dec 28, 2009 5:49 am

HELP!

Post by Daniel Farewell »

Payment: 1000 erb
To: first one who gets this script to work on a webpage

Code: Select all

<script>
/* 

TREESIAN DATE SCRIPT

  by Sander Dieleman

*/

// Init date
DateObj = new Date;
Day=DateObj.getDate();
Year=DateObj.getYear();
Month=DateObj.getMonth()+1;
var TreMonth, TreYear;

// Days Passed In the Current Year
DaysPassedCurrentYear = Day;
if (Month>11)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 30;}
if (Month>10)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 31;}
if (Month>9)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 30;}
if (Month>8)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 31;}
if (Month>7)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 31;}
if (Month>6)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 30;}
if (Month>5)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 31;}
if (Month>4)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 30;}
if (Month>3)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 31;}
if (Month>2)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 28;}
if (Month>1)
{DaysPassedCurrentYear = DaysPassedCurrentYear + 31;}

// Calculating the Treesian Month and the days passed in that month
TreYear=(Year%100)-2
if (DaysPassedCurrentYear > 17)
{
    if (DaysPassedCurrentYear > 47)
   {
       if (DaysPassedCurrentYear > 77)
      {
          if (DaysPassedCurrentYear > 107)
         {         
            if (DaysPassedCurrentYear > 137)
            {
                if (DaysPassedCurrentYear > 167)
               {
                   if (DaysPassedCurrentYear > 197)
                  {
                      if (DaysPassedCurrentYear > 227)
                     {
                         if (DaysPassedCurrentYear > 257)
                        {
                            if (DaysPassedCurrentYear > 287)
                           {
                                if (DaysPassedCurrentYear > 292)
                              {
                              TreYear=Year-2001;
                                 if (DaysPassedCurrentYear > 322)
                                {
                                      if (DaysPassedCurrentYear > 352)
                                        {TreMonth = 3;
                                        DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 352;}
                                        else
                                        {TreMonth = 2;
                                        DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 322;}
                                 }
                                else
                                     {TreMonth = 1;
                                      DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 292;
                                }
                              }
                              else
                                  {TreMonth = 13;
                                 DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 287;}
                           }
                           else
                             {TreMonth = 12;
                             DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 257;}
                        }
                        else
                           {TreMonth = 11;
                         DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 227;}
                     }
                     else
                     {TreMonth = 10;
                     DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 197;}
                  }
                  else
                  {TreMonth = 9;
                  DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 167;}
               }
               else
                 {TreMonth = 8;
               DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 137;}   
            }
            else
            {TreMonth = 7;
            DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 107;}   
         }
         else
         {TreMonth = 6;
         DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 77;}   
      }
      else
      {TreMonth = 5; 
      DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 47;}
   }
   else
   {TreMonth = 4;
   DaysPassedCurrentTreMonth = DaysPassedCurrentYear - 17;}
}
else
{TreMonth = 3; 
DaysPassedCurrentTreMonth = DaysPassedCurrentYear+13;}

// Outputting the date in the correct way of writing
TreMonthLong=new Array;
TreMonthLong[1]="Silnua";
TreMonthLong[2]="Cuspor";
TreMonthLong[3]="Gevracoon";
TreMonthLong[4]="Gevraderr";
TreMonthLong[5]="Filladin";
TreMonthLong[6]="Fasmas";
TreMonthLong[7]="Nomedsiocc";
TreMonthLong[8]="Laemil";
TreMonthLong[9]="Rocpinn";
TreMonthLong[10]="Uiscasla";
TreMonthLong[11]="Oscaltec";
TreMonthLong[12]="Mulantog";
TreMonthLong[13]="Chinnam";

// number ending stuff
DaysPassedCurrentTreMonthString = DaysPassedCurrentTreMonth.toString();
NumberLength = DaysPassedCurrentTreMonthString.length;
LastPartOfNumber = DaysPassedCurrentTreMonthString.charAt(NumberLength-1); //gettin the last part of the number
DaysPassedEnding="th";
if (LastPartOfNumber == 1)
{DaysPassedEnding="st";}
if (LastPartOfNumber == 2)
{DaysPassedEnding="nd";}
if (LastPartOfNumber == 3)
{DaysPassedEnding="rd";}
if (DaysPassedCurrentTreMonth == 11)
{DaysPassedEnding="th";}
if (DaysPassedCurrentTreMonth == 12)
{DaysPassedEnding="th";}
if (DaysPassedCurrentTreMonth == 13)
{DaysPassedEnding="th";}

// Special descriptions on Feastdays
var SpecialDesc="";

if (TreMonth==1)
{  
   if (DaysPassedCurrentTreMonth==14)
   {SpecialDesc="Tadding P�l's Eve";}
   if (DaysPassedCurrentTreMonth==15)
   {SpecialDesc="Tadding P�l Day";}
   if (DaysPassedCurrentTreMonth==16)
   {SpecialDesc="Festival of the Three";}
   if (DaysPassedCurrentTreMonth==17)
   {SpecialDesc="Festival of the Three";}
   if (DaysPassedCurrentTreMonth==18)
   {SpecialDesc="Festival of the Three";}
   if (DaysPassedCurrentTreMonth==12)
   {SpecialDesc="Ulcharam";}
   if (DaysPassedCurrentTreMonth==30)
   {SpecialDesc="Amariaa";}
}
if (TreMonth==2)
{
   if (DaysPassedCurrentTreMonth==19)
   {SpecialDesc="Sun";}
   if (DaysPassedCurrentTreMonth==23)
   {SpecialDesc="Seicha";}
}
if (TreMonth==3)
{
   if (DaysPassedCurrentTreMonth==6)
   {SpecialDesc="Utas";}
   if (DaysPassedCurrentTreMonth==11)
   {SpecialDesc="Salio";}
   if (DaysPassedCurrentTreMonth==28)
   {SpecialDesc="Runda";}
   if (DaysPassedCurrentTreMonth==29)
   {SpecialDesc="Mordic";}
}
if (TreMonth==5)
{
   if (DaysPassedCurrentTreMonth==14)
   {SpecialDesc="Caranna";}
   if (DaysPassedCurrentTreMonth==29)
   {SpecialDesc="Aincoim";}
}
if (TreMonth==6)
{
   if (DaysPassedCurrentTreMonth==1)
   {SpecialDesc="Lest & Elwynn";}
   if (DaysPassedCurrentTreMonth==12)
   {SpecialDesc="Uisceor";}
   if (DaysPassedCurrentTreMonth==30)
   {SpecialDesc="Paragon";}
}
if (TreMonth==7)
{
   if (DaysPassedCurrentTreMonth==1)
   {SpecialDesc="Dobharcufile";}
   if (DaysPassedCurrentTreMonth==17)
   {SpecialDesc="Ardescit";}
   if (DaysPassedCurrentTreMonth==25)
   {SpecialDesc="Folcador";}
   if (DaysPassedCurrentTreMonth==26)
   {SpecialDesc="Lochrinn";}
}
if (TreMonth==8)
{
   if (DaysPassedCurrentTreMonth==22)
   {SpecialDesc="Dlithail";}
}
if (TreMonth==9)
{
   if (DaysPassedCurrentTreMonth==6)
   {SpecialDesc="Laguna";}
   if (DaysPassedCurrentTreMonth==17)
   {SpecialDesc="Crandoigh";}
}
if (TreMonth==10)
{
   if (DaysPassedCurrentTreMonth==16)
   {SpecialDesc="Tineon";}
   if (DaysPassedCurrentTreMonth==24)
   {SpecialDesc="Maladaticc";}

}
if (TreMonth==11)
{
   if (DaysPassedCurrentTreMonth==5)
   {SpecialDesc="Mandorallen";}
   if (DaysPassedCurrentTreMonth==22)
   {SpecialDesc="Yetal";}
   if (DaysPassedCurrentTreMonth==24)
   {SpecialDesc="Bladhm";}
   if (DaysPassedCurrentTreMonth==27)
   {SpecialDesc="Ilass";}
}
if (TreMonth==12)
{
   if (DaysPassedCurrentTreMonth==5)
   {SpecialDesc="Leaigh";}
   if (DaysPassedCurrentTreMonth==9)
   {SpecialDesc="Rianna";}
   if (DaysPassedCurrentTreMonth==16)
   {SpecialDesc="Aeon";}
   if (DaysPassedCurrentTreMonth==24)
   {SpecialDesc="Carding";}
}
if (TreMonth==13)
{
   if (DaysPassedCurrentTreMonth==1)
   {SpecialDesc="Mourn for nations past";}
   if
(DaysPassedCurrentTreMonth==2)
   {SpecialDesc="Hope that past friends fare well in the future";}
   if
(DaysPassedCurrentTreMonth==3)
   {SpecialDesc="Celebrate that which is dear and gone";}
   if
(DaysPassedCurrentTreMonth==4)
   {SpecialDesc="Remember that destruction is a part of life";}
   if
(DaysPassedCurrentTreMonth==5)
   {SpecialDesc="Make provision for the future, learn from past mistakes";}
}

if (SpecialDesc!="")
{SpecialDesc = " - "+SpecialDesc}

       //ok here it goes...
      DateString=DaysPassedCurrentTreMonth+DaysPassedEnding+" "+TreMonthLong[TreMonth]+", "+TreYear+"DA"+SpecialDesc;
      document.write(" <b>"+DateString+"</b> ");

</script>

User avatar
Jonas
Posts: 5334
Joined: Mon Feb 19, 2007 9:53 am

Re: HELP!

Post by Jonas »

WHY...?! WHY...?!
DIDN'T I NEVER LEARN SCRIPTING?! :cry

1000 erbs... :cry
From a distance I'm concerned about the rampant lawyerism manifesting itself in Shireroth currently. A simple Kaiserial slap on the wrist or censure by the community should suffice. - Jacobus Loki
Can't you see? I'm crazy! :tomcutterhamonfire :smashy

User avatar
Ari Rahikkala
Posts: 4326
Joined: Sun Jan 21, 2001 12:56 pm
Contact:

Re: HELP!

Post by Ari Rahikkala »

This is 5% scripting and 95% integration anyway. Mind getting back on IRC if you're still awake, Ric? I'm proly going to have to run you through this by hand..
No-one should be without a parasol, Sirocco.

User avatar
Ari Rahikkala
Posts: 4326
Joined: Sun Jan 21, 2001 12:56 pm
Contact:

Re: HELP!

Post by Ari Rahikkala »

01:45 <@Daniel> i was waiting for you to fall :P
01:45 <@Daniel> at least you didnt stumble :P

:jesus :kaiser :jadie
No-one should be without a parasol, Sirocco.

User avatar
Ari Rahikkala
Posts: 4326
Joined: Sun Jan 21, 2001 12:56 pm
Contact:

Re: HELP!

Post by Ari Rahikkala »

Oh, right, I almost forgot: I fixed a bug in the datescript for the date converter... but not for the integrated date view (since I only noticed the bug when I was working on the converter). Here's a fixed version of overall_header.html (to be put in forum/styles/DarkFantasy/template as before) that won't display the wrong Treesian year after day 292 of the Gregorian year: http://ompldr.org/vNXE1dw/overall_header.html
No-one should be without a parasol, Sirocco.

Post Reply

Return to “Church of the Machine God”

Who is online

Users browsing this forum: No registered users and 3 guests