Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 767
  • Last Modified:

How can I create a Custom Clock on my userform?

I play an MMORPG that uses an in-game time system similar to normal "Earth" time.  I'm trying to create a program that can notify me when it's a certain time in the game, so I know that I need to log in.  I've been looking all over EE as well as other VB code websites, and can't seem to locate a code that will help me.  

An example of the time system can be viewed at http://www.pyogenes.com/ffxi/timer/v2.html.  All I need is the Information from the General Info box.  

I need the userform to have three clocks.  One in CST, One in GMT, and One in the game time.  I honestly don't even know where to begin with getting the game time on the form.  I need it to be constantly running, even when I'm not running the program, similar to the system clock, so that the time is always correct.  There may be a way to base it off of the system clock, but I'm not sure.

The time system is set up as follows:

There are 60 minutes in a day, 8 days in a week, 30 days in a month, 12 months in a year.

1 game second = .04 Real Seconds (1/25th of a second)
1 minute = 2.4 seconds
1 hour = 2 minutes 24 seconds
1 day = 57 minutes 36 seconds
1 Calendar month = 28 hours 48 minutes
1 Lunar month = 30 hours 43 minutes 12 seconds


My intent is to be able to base other functions off of both the in-game time, and the actual real life time, but I can't even begin working on the rest of it until I figure out how to get the time to work.

Thanks for your help.
0
Skidwiz
Asked:
Skidwiz
  • 5
  • 5
  • 4
1 Solution
 
Bob LearnedCommented:
Game time could be a Timer.  Do you want something like a status panel that displays the time?

Bob
0
 
SkidwizAuthor Commented:
Well, I'm not really sure.  I was planning on just using a textbox set to read only, and setting the Text to the Time.  Would it be easier to use a status panel?
0
 
Bob LearnedCommented:
You could use a status panel (2003) or StatusStrip (2005) to display the time.  

1 timer for game time with interval = 40 milliseconds (1/25 second)
1 timer for real time with interval = 1000 milliseconds (1 second)

In the timer Tick event handler, update the appropriate panel/label with the time.  The CST and GMT can be both displayed with timer #2, since you just need to use Date.ToUniversalTime to get GMT.

Bob
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SkidwizAuthor Commented:
Ok, I'm using VB Express 2005.  

I understand that I can use a timer for the tick event.  But what I don't know how to do is keep the clock running, and always correct, even if the program isn't running.  So, if I close the program today at 1027-07-14 10:20:43 in the Game time, then when I start it tomorrow, it won't still read that same time, or read all 0's.  Would using the timer accomplish that?  

Sorry if some of my questions seem a little off.  I've just started learning VB.Net coming from VBA.  So I don't understand a lot of it's functions just yet.
0
 
Bob LearnedCommented:
Can you define Game time?  Does that mean that once the game starts that the clock keeps running even if the game is running or the computer isn't turned on?

Bob
0
 
SkidwizAuthor Commented:
http://wiki.ffxiclopedia.org/Time defines everything you could possibly ever want to know about the game time.  It says, "Like, the real world, Vana'diel experiences both day and night, different days of the week, different months with varying seasons, and a full cycle of moon phases. Unlike the real world though, Vana'diel time is a very exact science; there is no leap year and every month consists of the same number of days. "  This page also has the actual time mechanics and formulas for converting real time to game time.

Otherwise, it is a Real-Time Game.  The clock in the game runs 24/7 (Or 24/8, by game time).  

This page explains the clocks, but not so much time.  http://wiki.ffxiclopedia.org/Vana%27diel_Clock   It's probably not important for you to check that one so much, although it has links to various webpages that display a clock similar to what I am wanting to create myself.  

If you want, I can explain why knowing the time is important, and how I intend to use it for the purpose of my application, if it will help you figure out how this needs to be tackled.  

But basically, since it's a real time clock, and is always running, I was thinking that basing it off of the system clock would be the easiest way to do it.  I'm not really all that sure though.

~Skid

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
What you need is a KNOWN-DEFINED game time and real time to work from as a reference.  Then you can take the current time, subtract the known time, and then calculate what the game time should be.
0
 
Bob LearnedCommented:
Yes, if you store a start time, then all you need to do is to calculate the differences for each time that you want from that start time.

Bob
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
This is ~REAL~ close...tinkered with it waaaaaaaaaay too long.

There might be a more efficient way to do the calculations but my head hurts thinking about time and parallel universes...   ;)

Public Class Form1

    Private WeekDays() As String = { _
        "Watersday", "Windsday", "Iceday", "Lightningday", _
        "Lightsday", "Darksday", "Firesday", "Earthsday"}
    Private VanadielSecondsPerEarthMinute As Decimal = 2.4
    Private EarthBaseDateTime As New DateTime(2007, 7, 31, 11, 50, 24)
    Private VanBaseDateTime As New DateTime(1027, 7, 15, 0, 0, 0)
    Private SecondsPerYear As Integer = New TimeSpan(360, 0, 0, 0).TotalSeconds
    Private SecondsPerMonth As Integer = New TimeSpan(30, 0, 0, 0).TotalSeconds
    Private SecondsPerDay As Integer = New TimeSpan(1, 0, 0, 0).TotalSeconds
    Private SecondsPerHour As Integer = New TimeSpan(1, 0, 0).TotalSeconds

    Private WithEvents tmr As New System.Windows.Forms.Timer()

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tmr.Interval = 100
        tmr.Start()
    End Sub

    Private Sub tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr.Tick
        Dim curDateTime As DateTime = DateTime.Now
        Dim ts As TimeSpan = curDateTime.Subtract(EarthBaseDateTime)
        Dim totalEarthSeconds As Decimal = ts.TotalSeconds
        Dim vanSeconds As Decimal = (totalEarthSeconds / VanadielSecondsPerEarthMinute) * 60

        Dim vanYears As Integer = vanSeconds \ SecondsPerYear
        vanSeconds = vanSeconds - (vanYears * SecondsPerYear)
        Dim vanMonths As Integer = vanSeconds \ SecondsPerMonth
        vanSeconds = vanSeconds - (vanMonths * SecondsPerMonth)
        Dim vanDays As Integer = vanSeconds \ SecondsPerDay
        vanSeconds = vanSeconds - (vanDays * SecondsPerDay)
        Dim vanHours As Integer = vanSeconds \ SecondsPerHour
        vanSeconds = vanSeconds - (vanHours * SecondsPerHour)
        Dim vanMinutes As Integer = vanSeconds \ 60
        vanSeconds = vanSeconds - (vanMinutes * 60)
        Dim vanWeekDay As String = WeekDays(vanDays Mod 8)

        Dim vanSecond As Integer = VanBaseDateTime.Second + vanSeconds
        If vanSecond >= 60 Then
            vanSecond = vanSecond Mod 60
            vanMinutes = vanMinutes + 1
        End If
        Dim vanMinute As Integer = VanBaseDateTime.Minute + vanMinutes
        If vanMinute >= 60 Then
            vanMinute = vanMinute Mod 60
            vanHours = vanHours + 1
        End If
        Dim vanHour As Integer = VanBaseDateTime.Hour + vanHours
        If vanHour >= 24 Then
            vanHour = vanHour Mod 24
            vanDays = vanDays + 1
        End If
        Dim vanDay As Integer = VanBaseDateTime.Day + vanDays
        If vanDay > 30 Then
            vanDay = vanDay Mod 30
            vanMonths = vanMonths + 1
        End If
        Dim vanMonth As Integer = VanBaseDateTime.Month + vanMonths
        If vanMonth > 12 Then
            vanMonth = vanMonth Mod 12
            vanYears = vanYears + 1
        End If
        Dim vanYear As Integer = VanBaseDateTime.Year + vanYears

        Label1.Text = vanWeekDay & ", " & vanYear & "-" & vanMonth.ToString("00") & "-" & vanDay.ToString("00") & " " & vanHour.ToString("00") & ":" & vanMinute.ToString("00") & ":" & vanSecond.ToString("00")
    End Sub

End Class
0
 
SkidwizAuthor Commented:
Idle_Mind

All I can say is, "Wow!".  You went above and beyond what I had expected with this question, and saved me hours of trying to find out how to implement the different variables, such as number of days in the week, and such.  I can see now why you're the number 2 expert on the hall of fame.  

You're right.  The program you wrote is very close to to the correct time.  Please forgive me when I say this, but math is not my strong subject, and I don't understand the formulas in the program above that you used to convert the time. I've been doing a lot of research on my own, trying to come up with the formula myself.  I'm a VBA user from Excel, so I used Excel to do the math.  The problem with excel is that it's date system doesn't want to conduct the proper math in order to figure out the time trend.  So, I cheated a bit, and opened up the webpage I posted in my original post, and saved it to my desktop.  This gave me access to the Javascript program that the programer used to get their time.  Unfortunately, like I said above, I'm not good at math, and I also don't know Java, so I can't understand it to convert it to VB.  I'll post their code at the bottom of this reply, so you can see what they did, and see where your math is off.  Hopefully that will help to get the above formula correct.  I also intend to try to figure the java code out, and convert it to your code.  I've never worked with time before in VBA or VB, so I'm having to learn all of this all as I go.  For instance, I have no clue how the New DateTime and TimeSpan work.  But I'll try to get it done as well, if I do, I'll post here with the answer.  

Thank you so much for all time and effort you applied to this.  I am very much in your debt.

Here's the Java code from the webpage.  The author put alot of comments in it to explain what they are doing, which is very helpful, and which makes me think there's a chance I may be able to convert it myself.  But, I'm worried it may be beyond my ability.

<!--


// basis date is used to convert real time to game time.
// Use UTC functions to allow calculations to work for any timezone
basisDate = new Date();
basisDate.setUTCFullYear(2002, 5, 23); // Set date to 2003-06-23
basisDate.setUTCHours(15, 0, 0, 0);    // Set time to 15:00:00.0000

// moon date is used to determien the current hase of the moon.
// Use UTC functions to allow calculations to work for any timezone
Mndate = new Date();
Mndate.setUTCFullYear(2004, 0, 25); // Set date to 2004-01-25
Mndate.setUTCHours(2, 31, 12, 0);    // Set time to 02:31:12.0000

// basis date for RSE calculations
RSEdate = new Date();
RSEdate.setUTCFullYear(2004, 0, 28); // Set date to 2004-01-28
RSEdate.setUTCHours(9, 14, 24, 0);    // Set time to 09:14:24.0000

// basis date for day of week calculations
Daydate = new Date();
Daydate.setUTCFullYear(2004, 0, 28); // Set date to 2004-01-28
Daydate.setUTCHours(9, 14, 24, 0);    // Set time to 09:14:24.0000

EarthDay = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
VanaDay = new Array("Firesday", "Earthsday", "Watersday", "Windsday", "Iceday", "Lightningday", "Lightsday", "Darksday");
DayColor = new Array("#DD000", "#AAAA00", "#0000DD", "#00AA22", "#7799FF", "#AA00AA", "#AAAAAA", "#333333");
weakMagic = new Array("Ice","Lightning","Fire","Earth","Wind","Water","Darkness","Light");
weakColor = new Array("#7799FF", "#AA00AA", "#DD000", "#AAAA00", "#00AA22", "#0000DD", "#333333", "#AAAAAA");
PhaseName = new Array("Full Moon","Waning Gibbous","Last Quarter","Waning Crescent","New Moon","Waxing Crescent","First Quarter","Waxing Gibbous");

sMonth = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
RSErace = new Array("M. Hume","F. Hume","M. Elvaan","F. Elvaan","M. TaruTaru","F. TaruTaru","Mithra","Galka");
RSEloc = new Array("Gusgen Mines","Shakrami Maze","Ordelle Caves");
BoatSched = new Array("08:00", "16:00", "00:00");
BoatSched2 = new Array("06:30", "14:30", "22:30");
BoatDayOffset = new Array(0,0,7);

msGameDay      = (24 * 60 * 60 * 1000 / 25); // milliseconds in a game day
msRealDay      = (24 * 60 * 60 * 1000); // milliseconds in a real day

balJug = new Array("","Entry ","Match ","Closing Ceremony ","","");
balPas = new Array("", "", "", "Entry ","Match ","Closing Ceremony ");
balMer = new Array("Match ","Closing Ceremony ", "", "", "", "Entry ");
balJugTeam = new Array("San D'oria vs Bastok", "Bastok vs Windurst", "San D'oria vs Windurst");
balPasTeam = new Array("Bastok vs Windurst", "San D'oria vs Windurst", "San D'oria vs Bastok");
balMerTeam = new Array("San D'oria vs Windurst", "San D'oria vs Bastok", "Bastok vs Windurst");


//**************
// Functions  **
//**************


function getVanadielTime()  {

   var now = new Date();
   vanaDate =  ((898 * 360 + 30) * msRealDay) + (now.getTime() - basisDate.getTime()) * 25;

   vYear = Math.floor(vanaDate / (360 * msRealDay));
   vMon  = Math.floor((vanaDate % (360 * msRealDay)) / (30 * msRealDay)) + 1;
   vDate = Math.floor((vanaDate % (30 * msRealDay)) / (msRealDay)) + 1;
   vHour = Math.floor((vanaDate % (msRealDay)) / (60 * 60 * 1000));
   vMin  = Math.floor((vanaDate % (60 * 60 * 1000)) / (60 * 1000));
   vSec  = Math.floor((vanaDate % (60 * 1000)) / 1000);
   vDay  = Math.floor((vanaDate % (8 * msRealDay)) / (msRealDay));

   if (vYear < 1000) { VanaYear = "0" + vYear; } else { VanaYear = vYear; }
   if (vMon  < 10)   { VanaMon  = "0" + vMon; }  else { VanaMon  = vMon; }
   if (vDate < 10)   { VanaDate = "0" + vDate; } else { VanaDate = vDate; }
   if (vHour < 10)   { VanaHour = "0" + vHour; } else { VanaHour = vHour; }
   if (vMin  < 10)   { VanaMin  = "0" + vMin; }  else { VanaMin  = vMin; }
   if (vSec  < 10)   { VanaSec  = "0" + vSec; }  else { VanaSec  = vSec; }

   VanaTime = "<DIV onmouseover='javascript:dayDetails(vDay)'><FONT COLOR=" + DayColor[vDay] + ">" + VanaDay[vDay] + "</FONT>:  "
   VanaTime += VanaYear + "-" + VanaMon + "-" + VanaDate + "  " + VanaHour + ":" + VanaMin + ":" + VanaSec + "</DIV>";

   document.getElementById("vTime").innerHTML = VanaTime;
   
   getBallistaSummary(vDate, vMon);
}

function getBallistaSummary(vDate, vMon)  {
   out = "";
   for ( i = 0; i < 3; i++) {
      vDate = vDate + 1;
      if (vDate > 30) {
         vDate = 1;
         vMon = vMon + 1;
      }


      if (vDate <= 6)  {
         balLimit = "30";
      } else if (vDate <=12)  {
         balLimit = "40";
      } else if (vDate <=18)  {
         balLimit = "50";
      } else if (vDate <=24)  {
         balLimit = "60";
      } else if (vDate <=30)  {
         balLimit = "None";
      }

      balTeam = Math.floor((vMon - 1) / 4);
   
      balJugner = balJug[vDate % 6];
      if (balJugner != "") {
         balJugner = "Jugner Forest: " + balJugner + "for " + balJugTeam[balTeam] + " with a level cap of: " + balLimit + "<BR>";
      }
      balPashhow = balPas[vDate % 6];
         if (balPashhow != "") {
            balPashhow = "Pashhow Marshlands: " + balPashhow + "for " + balPasTeam[balTeam] + " with a level cap of: " + balLimit + "<BR>";
      }
      balMeriph = balMer[vDate % 6];
         if (balMeriph != "") {
            balMeriph = "Meriphataud Mountains: " + balMeriph + "for " + balMerTeam[balTeam] + " with a level cap of: " + balLimit + "<BR>";
      }
     
      out = out + balJugner + balPashhow + balMeriph + "<HR>";
   }

}

function dayDetails(firstDay)  {

   out = '<TABLE CLASS="blank" CELLPADDING="0" CELLSPACING="0">';
   out = out + '<TR><TH WIDTH=80 ALIGN="left">Day</TH><TH>Weak Element</TH></TR>';
   out = out + '<TR><TD VALIGN="TOP">';
   for ( i = 0; i < 8; i++) {
      if (i != 0) { out = out + '<BR>';}
      out = out + '<FONT COLOR=' + DayColor[(firstDay + i) % 8] + '>' + VanaDay[(firstDay + i) % 8] + '</FONT>';
   }
   
   out = out + '</TD><TD>';
   for ( i = 0; i < 8; i++) {
      if (i != 0) { out = out + '<BR>';}
      out = out + '<FONT COLOR=' + weakColor[(firstDay + i) % 8] + '>' + weakMagic[(firstDay + i) % 8] + '</FONT>';
   }
   
   out = out + '</TD></TR></TABLE>'
   document.getElementById("Details").innerHTML = out;

}

function clearDetails()  {

      document.getElementById("Details").innerHTML = '';

}

function getEarthTime()  {

   var now = new Date();
   earthTime = formatDate(now.getTime(), 1);
   document.getElementById("eTime").innerHTML = earthTime;

}

function getConquest()  {

   var now = new Date();
   var timeLeft = (7 * msRealDay) - ((now.getTime() - basisDate.getTime()) % (7 * msRealDay));
   vanaConq = Math.floor(timeLeft / (msGameDay)) + 1;

   conqDays = timeLeft / msRealDay;
   conqHours = (conqDays - Math.floor(conqDays)) * 24;
   conqMin = (conqHours - Math.floor(conqHours)) * 60;
   conqSec = Math.floor((conqMin - Math.floor(conqMin)) * 60);

   if (conqDays < 10) { conqDays = '0' + Math.floor(conqDays); } else { conqDays = Math.floor(conqDays); }
   if (conqHours < 10) { conqHours = '0' + Math.floor(conqHours ); } else { conqHours = Math.floor(conqHours ); }
   if (conqMin < 10) { conqMin = '0' + Math.floor(conqMin ); } else { conqMin = Math.floor(conqMin ); }
   if (conqSec < 10) { conqSec = '0' + Math.floor(conqSec ); } else { conqSec = Math.floor(conqSec ); }
   
   conqDate = formatDate(now.getTime() + timeLeft, 2);

   conq = vanaConq + ' Vana´diel Days <BR>' + conqDate + ' (' + formatCountdown(timeLeft) + ')';
   document.getElementById("conquest").innerHTML = conq;
}

function getRSE()  {
   var timenow = new Date();
   var localtime = timenow.getTime();
   var RSEtime = RSEdate.getTime();
   var repeatCal = document.Timer.RSE.value;
   var race = document.Timer.RSErace.value;

   if (race > 7) {
      RSECal = "<TABLE CLASS='blank' CELLPADDING='0' CELLSPACING='0'><TR><TH WIDTH='120' ALIGN='LEFT'>Date & Time</TH><TH WIDTH='90' ALIGN='LEFT'>Race</TH><TH WIDTH='90' ALIGN='LEFT'>Location</TH></TR>"
      for ( i = 0; i < repeatCal; i++) {
         elapsedWeeks = Math.floor( (localtime - RSEtime) / (8 * msGameDay) ) + i;
         RSEstart = RSEtime + (elapsedWeeks * 8 * msGameDay);
         RSECal = RSECal + "<TR><TD>" + formatDate(RSEstart,2) + '</TD><TD>' + RSErace[elapsedWeeks % 8] + '</TD><TD>';
         RSECal = RSECal + "<A HREF=#  onmousedown='javascript:getRSEDetails(" + (elapsedWeeks % 3) + ")'>";
         RSECal = RSECal + RSEloc[elapsedWeeks % 3]
         RSECal = RSECal + '</A></TD></TR>';
      }
     if (repeatCal < 1) { RSECal = ""; } else { RSECal = RSECal + '</TABLE>'; }
   } else {
      RSECal = "<TABLE CLASS='blank' CELLPADDING='0' CELLSPACING='0'><TR><TH WIDTH='120' ALIGN='LEFT'>Start</TH><TH WIDTH='120' ALIGN='LEFT'>End</TH><TH WIDTH='60' ALIGN='LEFT'>Location</TH></TR>"
      offsetTime = race * 8 * msGameDay;

      for ( i = 0; i < repeatCal; i++) {
         elapsedWeeks = Math.floor( (localtime - RSEtime) / (64 * msGameDay) ) + i;
         
         elapsedLocationWeeks = Math.floor( (localtime - RSEtime) / (8 * msGameDay) ) + (8 * i);
         raceOffset = race - (elapsedLocationWeeks % 8);
         elapsedLocationWeeks = elapsedLocationWeeks + raceOffset;

         RSEstart = RSEtime + (elapsedWeeks * 64 * msGameDay) + offsetTime ;
         RSEend = RSEstart + (8 * msGameDay);
         RSECal = RSECal + "<TR><TD>" + formatDate(RSEstart,2) + "</TD><TD>" + formatDate(RSEend,2) + "</TD><TD>";
         RSECal = RSECal + "<A HREF=#  onmousedown='javascript:getRSEDetails(" + (elapsedLocationWeeks % 3) + ")'>";
         RSECal = RSECal + RSEloc[(elapsedLocationWeeks) % 3]
         RSECal = RSECal + "</A></TD></TR>";
      }
     if (repeatCal < 1) { RSECal = ""; } else { RSECal = RSECal + '</TABLE>'; }

   }

   document.getElementById("rCal").innerHTML = RSECal;


}

function getRSEDetails(varLocation)  {

   if (varLocation == 0)  {
      output = "<TABLE CLASS='blank'><TR><TH ALIGN='left'>Key Droppers</TH><TH></TH><TH></TH></TR>";
      output = output + "<TR><TD VALIGN = 'TOP' WIDTH='75'>Sad Fly<BR>Gallinipper<BR>Rancid Ooze<BR>";      
      output = output + "Banshee<BR>Mauthe Dog<BR>Myconid<BR>Wight</TD>";
      output = output + "<TD VALIGN = 'TOP' WIDTH='85'>Ghast<BR>Wendigo<BR>Spunkie<BR>";
      output = output + "Amphisbeana<BR>Thunder Elemental<BR>Greater Pugil</TD>";
      output = output + "</TR></TABLE>";

   } else if (varLocation == 1) {
      output = "<TABLE CLASS='blank'><TR><TH ALIGN='left'>Key Droppers</TH><TH></TH></TR>";
      output = output + "<TR><TD VALIGN = 'TOP'>Goblin Furrier<BR>Goblin Shaman<BR>";
      output = output + "Goblin Pathfinder<BR>Goblin Smithy<BR>Caterchipillar<BR>Wight<BR>";
      output = output + "<TD VALIGN = 'TOP' WIDTH='75'>Labyrinth Scorpion<BR>Abyss Worm<BR>Protozoan<BR>Air Elemental<BR>";
      output = output + "Ichorous Ire</TD></TR></TABLE>";

   } else if (varLocation == 2) {
      output = "<TABLE CLASS='blank'><TR><TH ALIGN='left'>Key Droppers</TH><TH></TH></TR>";
      output = output + "<TR><TD VALIGN = 'TOP' WIDTH='75'>Air Elemental<BR>Goblin Shaman<BR>Goblin Smithy<BR>";
      output = output + "Goblin Pathfinder<BR>Goliath Beetle<BR></TD>";
      output = output + "<TD VALIGN = 'TOP' WIDTH='90'>Napam<BR>Stroper<BR>";
      output = output + "Stroper Chyme<BR>Water Elemental</TD>";
      output = output + "</TR></TABLE>";

   }

   document.getElementById("Details").innerHTML = output;
}


function getMoonPhase()  {

   var timenow = new Date();
   var localTime = timenow.getTime();
   var moonDays = (Math.floor((localTime - Mndate.getTime()) / msGameDay))  % 84;

   var mnElapsedTime = (localTime - Mndate.getTime()) % msGameDay;

   // determine phase percentage
         moonpercent = - Math.round((42 - moonDays) / 42 * 100);
         if (moonpercent <= -94)  {
            mnPhase = 0;
            optPhase = 4;
            toNextPhase = (3 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (38 - moonDays) * msGameDay - mnElapsedTime;

         }  else if (moonpercent >= 90)  {
          mnPhase = 0;
            optPhase = 4;
            toNextPhase = (87 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (38 + 84 - moonDays) * msGameDay - mnElapsedTime;

         }  else if (moonpercent >= -93 && moonpercent <= -62)  {
            mnPhase = 1;
            optPhase = 4;
            toNextPhase = (17 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (38 - moonDays) * msGameDay - mnElapsedTime;

         }  else if (moonpercent >= -61 && moonpercent <= -41)  {
            mnPhase = 2;
            optPhase = 4;
            toNextPhase = (25 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (38 - moonDays) * msGameDay - mnElapsedTime;

         }  else if (moonpercent >= -40 && moonpercent <= -11)  {
            mnPhase = 3;
            optPhase = 4;
            toNextPhase = (38 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (38 - moonDays) * msGameDay - mnElapsedTime;

         }  else if (moonpercent >= -10 && moonpercent <= 6)  {
            mnPhase = 4;
            optPhase = 0;
            toNextPhase = (45 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (80 - moonDays) * msGameDay - mnElapsedTime;

         }  else if (moonpercent >= 7 && moonpercent <= 36)  {
            mnPhase = 5;
            optPhase = 0;
            toNextPhase = (58 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (80 - moonDays) * msGameDay - mnElapsedTime;

         }  else if (moonpercent >= 37 && moonpercent <= 56)  {
            mnPhase = 6;
            optPhase = 0;
            toNextPhase = (66 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (80 - moonDays) * msGameDay - mnElapsedTime;

         }  else if (moonpercent >= 57 && moonpercent <= 89)  {
            mnPhase = 7;
            optPhase = 0;
            toNextPhase = (60 - moonDays) * msGameDay - mnElapsedTime;
            toOptimalPhase = (80 - moonDays) * msGameDay - mnElapsedTime;
         }

         mnpercent = PhaseName[mnPhase] + " (" + Math.abs(moonpercent) + "%)";

         if (moonpercent <= 5 && moonpercent >= -10)  {
              mnpercent = "<FONT COLOR='#FF0000'>" + mnpercent+ "</FONT>";
         } else if (moonpercent >= 90 || moonpercent <= -95)  {
              mnpercent = "<FONT COLOR='#0000FF'>" + mnpercent+ "</FONT>";
         }

   nextPhase = "Next phase (" + PhaseName[(mnPhase + 1) % 8] + "): " + formatCountdown(toNextPhase);
   nextOptPhase = "Next " + PhaseName[optPhase] + ": " + formatCountdown(toOptimalPhase);

   mnpercent = "<DIV onmouseover='javascript:getMoonDetails()'>" + mnpercent + "</DIV>  ";
   
   document.getElementById("mPhase").innerHTML = mnpercent + nextPhase + "<BR>" + nextOptPhase;



   // new moon starts on day 38 (-10%)
   // full moon starts at 80 (90%)
   // Moon cycle lasts 84 game days.

   // Determine most recent full moon
   var fullMoonBasis = Mndate.getTime() + (3 * msGameDay);
   var repeatCal = document.Timer.Moon.value;

   moonCal = "<TABLE CLASS='blank' CELLSPACING='0' CELLPADDING='0'><TR><TH WIDTH='95' ALIGN='left'>New Moon Start</TH><TH WIDTH='105' ALIGN='left'>New Moon End</TH><TH WIDTH='95' ALIGN='left'>Full Moon Start</TH><TH WIDTH='78' ALIGN='left'>Full Moon End</TH></TR>";
   for ( i = 0; i < repeatCal; i++)  {
      elapsedCycles = Math.floor( (localTime - fullMoonBasis) / (84 * msGameDay) ) + i;
      FullEnd = fullMoonBasis + (elapsedCycles * 84 * msGameDay);
      //Full Moon starts 7 games days prior to end
      FullStart = FullEnd - 7 * msGameDay;
      //New Moon starts 49 games days prior to Full Moon end
      NewStart = FullEnd - 49 * msGameDay;
      //New Moon ends 42 games days prior to Full Moon end
      NewEnd = FullEnd - 42 * msGameDay;

      moonCal = moonCal + "<TR><TD>" + formatDate(NewStart, 2) + "</TD><TD>" + formatDate(NewEnd, 2) + "</TD><TD>" + formatDate(FullStart,2) + "</TD><TD>" + formatDate(FullEnd, 2) + "</TD></TR>";
   }
   if (repeatCal < 1) { moonCal = ""; } else { moonCal = moonCal + '</TABLE>'; }
   document.getElementById("mCalendar").innerHTML = moonCal;

}

function getMoonDetails()  {

   out = "Moon Information:";
   out = out + "<BR>Each lunar cycle takes exactly 84 game days (3 days, 8 hours, 38 minutes, 24 seconds)";
   
   document.getElementById("Details").innerHTML = out;


}

function getShipSched()  {

   // Boats depart at 00:00, 08:00, 16:00 from both Selbina and Mhuara
   // Boats arrive at 06:30, 14:30, 22:30 which is 216 seconds before they leave
   var now = new Date();
   var timeDiff = now.getTime() - basisDate.getTime();
   var hours = Math.floor((timeDiff / ( msGameDay / 3)) % 3);

   var timeLeft = (msGameDay / 3 ) - (timeDiff % (msGameDay / 3));

   var repeatFerry = document.Timer.FerryCount.value;

   bSched = "<TABLE CLASS='blank' CELLSPACING='0' CELLPADDING='0'><TR><TH WIDTH='80' ALIGN='left'>Arrives</TH>";
   bSched = bSched + "<TH WIDTH='45'></TH><TH ALIGN='left' WIDTH='80'>ETA</TH>";
   bSched = bSched + "<TH WIDTH='80' ALIGN='left'>Departs</TH><TH WIDTH='45'></TH>";
   bSched = bSched + "<TH ALIGN='left' WIDTH='45'>ETD</TH></TR>";

   vanaDate =  ((898 * 360 + 30) * msRealDay) + (timeDiff) * 25;
   vDay  = Math.floor((vanaDate % (8 * msRealDay)) / (msRealDay));

   for ( i = 0; i < repeatFerry; i++) {
      timeLeftLoop = timeLeft + ( i* msGameDay / 3);
      dPos = (vDay + Math.floor((hours + 1 + i)/3)) % 8;
      dPos2 = (dPos + BoatDayOffset[(hours + i) % 3]) % 8;
      arrivalTime = timeLeftLoop - 216000;
      if (arrivalTime <= 0)
         arrivalTime = 0;

      bSched = bSched + '<TR><TD><FONT COLOR="' + DayColor[dPos2] + '">' + VanaDay[dPos2] + '</FONT></TD><TD>' + BoatSched2[(hours + i) % 3] + '</TD><TD>' + formatCountdown(arrivalTime) + '</TD><TD><FONT COLOR="' + DayColor[dPos] + '">' + VanaDay[dPos] + '</FONT></TD><TD>' + BoatSched[(hours + i) % 3] + '</TD><TD ALIGN="left">' + formatCountdown(timeLeftLoop) + '</TD></TR>';
   }

   if (repeatFerry < 1) { out = ''; } else { out = bSched + "</TABLE>"; }
   document.getElementById("ferry").innerHTML = out;

}

function getAirSched() {

   var timenow = new Date();
   var localTime = timenow.getTime();
   var elapsedTime = (localTime - basisDate.getTime()) % msGameDay;
   var dayStart = localTime - elapsedTime;
   vanaDate = ((898 * 360 + 30) * msRealDay) + (localTime - basisDate.getTime()) * 25;
   vDay = Math.floor((vanaDate % (8 * msRealDay)) / (msRealDay));

   var offset1 = ((1 * 60) + 10) * 60 * 1000 / 25; // 1:10 offset used by B->J J->S
   var offset2 = ((2 * 60) + 40) * 60 * 1000 / 25; // 2:40 offset used by J->W K-J
   var offset3 = ((4 * 60) + 10) * 60 * 1000 / 25; // 4:10 offset used by J->B S->J
   var offset4 = ((5 * 60) + 35) * 60 * 1000 / 25; // 5:35 offset used by J->K
   var offset5 = ((5 * 60) + 45) * 60 * 1000 / 25; // 5:45 offset used by W->J

   outAir = "";
   outAir += "<TABLE CLASS='blank' WIDTH='400' CELLSPACING='0' CELLPADDING='0'>";
   outAir += "<TR><TH ALIGN='LEFT'>Airship Route</TH>";
   outAir += "<TH ALIGN='LEFT'>Departure Day</TH>";
   outAir += "<TH ALIGN='LEFT'>Arrival</TH>";
   outAir += "<TH ALIGN='LEFT'>Departure</TH></TR>";
   
   outAir += AirHelper(elapsedTime, offset3, vDay, "Jeuno To Bastok");
   outAir += AirHelper(elapsedTime, offset4, vDay, "Jeuno To Kazham");
   outAir += AirHelper(elapsedTime, offset1, vDay, "Jeuno To San d'Oria");
   outAir += AirHelper(elapsedTime, offset2, vDay, "Jeuno To Windurst");
   outAir += AirHelper(elapsedTime, offset1, vDay, "Bastok To Jeuno");
   outAir += AirHelper(elapsedTime, offset2, vDay, "Kazham To Jeuno");
   outAir += AirHelper(elapsedTime, offset3, vDay, "San d'Oria To Jeuno");
   outAir += AirHelper(elapsedTime, offset5, vDay, "Windurst To Jeuno");
   
   outAir += "</TABLE>";
   
   document.getElementById("Airship").innerHTML = outAir;
}

function AirHelper(elapsed, offset, day, city) {

   var newOffset = offset;
   var count = 0;
   while (newOffset < elapsed) {
      count += 1;
      newOffset += (msGameDay / 4);
   }
   if (count >= 4) {
      day = (day + 1) % 8;
   }
   
   
   output = "<TR><TD>" + city + "</TD>";
   output += "<TD><FONT COLOR=" + DayColor[day] + ">" + VanaDay[day] + "</FONT></TD>";
   arrivalTime = newOffset - elapsed - 144000;
   if (arrivalTime < 0)  {
      arrivalTime = 0;
   }
   output += "<TD>" + formatCountdown(arrivalTime,1) + "</TD>";
   output += "<TD>" + formatCountdown(newOffset - elapsed,1) + "</TD></TR>";
   
   return output;
}



function getDaySched()  {


   var now = new Date();
   var timeDiff = now.getTime() - Mndate.getTime();
   var weekStart = now.getTime() - (timeDiff % (8 * msGameDay));

   var repeatCal = document.Timer.DayCount.value;
   var dayOffset = document.Timer.Day.value;  
   
   var out = "<TABLE CLASS='blank' CELLSPACING='0' CELLPADDING='0'><TR><TH WIDTH='75' ALIGN='left'>Day</TH><TH WIDTH='100' ALIGN='left'>Begins</TH><TH ALIGN='left' WIDTH='100'>Ends</TH><TH ALIGN='left' WIDTH='120'>Moon Phase</TH></TR>";
   if (dayOffset > 7) {
      for ( i = 0; i < repeatCal; i++) {
         startTime = weekStart + ((dayOffset - 14) * msGameDay) + (msGameDay * i);
         endTime = startTime + msGameDay;

         moonDays = (Math.floor((startTime - Mndate.getTime()) / msGameDay))  % 84;
         // determine phase percentage
         moonpercent = - Math.round((42 - moonDays) / 42 * 100);

         if (moonpercent <= -94)  {
              mnPhase = 0;

         }  else if (moonpercent >= 90)  {
            mnPhase = 0;

         }  else if (moonpercent >= -93 && moonpercent <= -62)  {
            mnPhase = 1;

         }  else if (moonpercent >= -61 && moonpercent <= -41)  {
            mnPhase = 2;

         }  else if (moonpercent >= -40 && moonpercent <= -11)  {
            mnPhase = 3;

         }  else if (moonpercent >= -10 && moonpercent <= 6)  {
            mnPhase = 4;

         }  else if (moonpercent >= 7 && moonpercent <= 38)  {
            mnPhase = 5;
            
         }  else if (moonpercent >= 37 && moonpercent <= 56)  {
            mnPhase = 6;

         }  else if (moonpercent >= 57 && moonpercent <= 89)  {
            mnPhase = 7;
            
         }
         
         mnpercent = PhaseName[mnPhase] + " (" + Math.abs(moonpercent) + "%)";

         if (moonpercent <= 5 && moonpercent >= -10)  {
              mnpercent = "<FONT COLOR='#FF0000'>" + mnpercent + "</FONT>";
         } else if (moonpercent >= 90 || moonpercent <= -95)  {
              mnpercent = "<FONT COLOR='#0000FF'>" + mnpercent + "</FONT>";
         }

         out = out + "<TR><TD><FONT COLOR='" + DayColor[(dayOffset + i) % 8] + "'>" + VanaDay[(dayOffset + i) % 8] + "</FONT></TD><TD>" + formatDate(startTime, 2) + "</TD><TD>" + formatDate(endTime, 2) + "</TD><TD>" + mnpercent + "</TD></TR>";
      }
   
   } else {
      for ( i = 0; i < repeatCal; i++) {
         startTime = weekStart + ((dayOffset - 6) * msGameDay) + (8 * msGameDay * i);
         endTime = startTime + msGameDay;

         moonDays = (Math.floor((startTime - Mndate.getTime()) / msGameDay))  % 84;
         // determine phase percentage
         moonpercent = - Math.round((42 - moonDays) / 42 * 100);
         if (moonpercent <= -94)  {
          mnPhase = 0;
      
       } else if (moonpercent >= 90)  {
            mnPhase = 0;
      
         }  else if (moonpercent >= -93 && moonpercent <= -62)  {
            mnPhase = 1;
      
         }  else if (moonpercent >= -61 && moonpercent <= -41)  {
            mnPhase = 2;
      
         }  else if (moonpercent >= -40 && moonpercent <= -11)  {
            mnPhase = 3;
      
         }  else if (moonpercent >= -10 && moonpercent <= 6)  {
            mnPhase = 4;
      
         }  else if (moonpercent >= 7 && moonpercent <= 38)  {
            mnPhase = 5;
                   
         }  else if (moonpercent >= 37 && moonpercent <= 56)  {
            mnPhase = 6;
      
         }  else if (moonpercent >= 57 && moonpercent <= 89)  {
            mnPhase = 7;
                   
         }
         
         mnpercent = PhaseName[mnPhase] + " (" + Math.abs(moonpercent) + "%)";
         
         if (moonpercent <= 5 && moonpercent >= -10)  {
              mnpercent = "<FONT COLOR='#FF0000'>" + mnpercent + "</FONT>";
         } else if (moonpercent >= 90 || moonpercent <= -95)  {
              mnpercent = "<FONT COLOR='#0000FF'>" + mnpercent + "</FONT>";
         }

         out = out + "<TR><TD><FONT COLOR='" + DayColor[dayOffset] + "'>" + VanaDay[dayOffset] + "</FONT></TD><TD>" + formatDate(startTime, 2) + "</TD><TD>" + formatDate(endTime, 2) + "</TD><TD>" + mnpercent + "</TD></TR>";
      }
   }
   if (repeatCal < 1) { out = ''; } else { out = out + "</TABLE>"; }
   document.getElementById("days").innerHTML = out;
}

function getGuildHours()  {
   
   alchemy = guildHelper(8, 23, 6);
   blacksmith = guildHelper(8, 23, 2);
   bonework = guildHelper(8, 23, 3);
   goldsmith = guildHelper(8, 23, 4);
   cloth = guildHelper(6, 21, 0);
   wood = guildHelper(6, 21, 0);
   leather = guildHelper(3, 18, 4);
   fishing = guildHelper(3, 18, 5);
   cooking = guildHelper(5, 20, 7);


   guildOut = "<TABLE CLASS='blank' CELLSPACING='0' CELLPADDING='0'>";
   guildOut = guildOut + "<TR><TH ALIGN='left' WIDTH=85>Guild</TH>";
   guildOut = guildOut + "<TH WIDTH=55></TH><TH WIDTH=50></TH><TH ALIGN='left' WIDTH=140>Status</TH></TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(1)'>Alchemy</A>"             + "</TD>" + alchemy       + "</TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(2)'>Blacksmith</A>"       + "</TD>" + blacksmith       + "</TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(3)'>Boneworking</A>"       + "</TD>" + bonework       + "</TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(4)'>Goldsmith</A>"       + "</TD>" + goldsmith       + "</TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(5)'>Cloth</A>"             + "</TD>" + cloth       + "</TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(6)'>Woodworking</A>"       + "</TD>" + wood       + "</TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(7)'>Leather</A>"             + "</TD>" + leather       + "</TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(8)'>Fishing</A>"             + "</TD>" + fishing       + "</TR>";
   guildOut = guildOut + "<TR><TD>" + "<A HREF=#  onmousedown='javascript:guildDetail(9)'>Cooking</A>"             + "</TD>" + cooking       + "</TR>";
   guildOut = guildOut + "</TABLE>";
   
   document.getElementById("Guilds").innerHTML = guildOut;


}

function guildHelper(open, close, holiday)  {
   var timenow = new Date();
   var localTime = timenow.getTime();
   var elapsedTime = (localTime - basisDate.getTime()) % msGameDay;
   var dayStart = localTime - elapsedTime;

   // this conversion factor tells us time elapsed since the game day started in milliseconds
   var convFactor = 60 * 60 * 1000 / 25;
   
   vanaDate =  ((898 * 360 + 30) * msRealDay) + (localTime - basisDate.getTime()) * 25;
   vDay  = Math.floor((vanaDate % (8 * msRealDay)) / (msRealDay));

   open = open * convFactor;
   close = close * convFactor;
   
   openTime = open + dayStart;
   closeTime = close + dayStart;
   outputTxt = "";
   guildCountdown = 0;
   
   if (openTime >= localTime) {
      guildCountdown = openTime - localTime;
      outputTxt2 = "</TD><TD><FONT COLOR='#DD0000'>Closed.</FONT> Open tomorrow.</TD>";
      outputTxt1 = "<TD>Opens in:</TD><TD>";
   } else if ((openTime < localTime) && (closeTime > localTime)) {
      guildCountdown = closeTime - localTime;
      outputTxt2 = "</TD><TD><FONT COLOR='#008822'>Open</FONT> for business</TD>";
      outputTxt1 = "<TD>Closes in:</TD><TD>";
   } else if (closeTime <= localTime)  {
      guildCountdown = (msGameDay - elapsedTime) + open;
      outputTxt2 = "</TD><TD><FONT COLOR='#DD0000'>Closed.</FONT> Open tomorrow.</TD>";
      outputTxt1 = "<TD>Opens in:</TD><TD>";      
   }
   
   // adjust for holiday
   if ((holiday == vDay) && (closeTime > localTime)) {
      guildCountdown = (msGameDay - elapsedTime) + open;
      outputTxt2 = "</TD><TD><FONT COLOR='#DD0000'>Closed</FONT> for Holiday</TD>";
      outputTxt1 = "<TD>Opens in:</TD><TD>";
   } else if (((vDay + 1) == holiday) && (closeTime <= localTime))  {
      guildCountdown = (msGameDay - elapsedTime) + open + msGameDay;
      outputTxt2 = "</TD><TD><FONT COLOR='#DD0000'>Closed.</FONT> Holiday tomorrow</TD>";
      outputTxt1 = "<TD>Opens in:</TD><TD>";
   }

   return outputTxt1 + formatCountdown(guildCountdown) + outputTxt2;
}

function guildDetail(guild)  {

   switch(guild)  {
      case 1:
         out = "Alchemist´s guild <BR>Location:  Bastok Mines<BR>Holiday:  Lightsday<BR>Hours:  8:00-23:00";
         break
      case 2:
         out = "Blacksmith´s guild <BR>Location:  Bastok Metalworks, Northern San d´Oria<BR>Holiday:  Watersday<BR>Hours:  8:00-23:00";
         break
      case 3:
         out = "Boneworker´s guild <BR>Location:  Windurst Woods<BR>Holiday:  Windsday<BR>Hours:  8:00-23:00";
         break
      case 4:
         out = "Goldsmith´s guild <BR>Location:  Bastok Market<BR>Holiday:  Iceday<BR>Hours:  8:00-23:00";
         break
      case 5:
         out = "Weaver´s guild <BR>Location:  Windurst Woods<BR>Holiday:  Firesday<BR>Hours:  6:00-21:00";
         break
      case 6:
         out = "Carpenter´s guild <BR>Location:   Northern San d´Oria<BR>Holiday:  Firesday<BR>Hours:  6:00-21:00";
         break
      case 7:
         out = "Leatherworker´s guild <BR>Location:   Southern San d´Oria<BR>Holiday:  Iceday<BR>Hours:  3:00-18:00";
         break
      case 8:
         out = "Fisherman´s guild <BR>Location:   Port Windurst<BR>Holiday:  Lightningday<BR>Hours:  3:00-18:00";
         break
      case 9:
         out = "Culinary guild <BR>Location:   Windurst Waters<BR>Holiday:  Darksday<BR>Hours:  5:00-20:00";
   }
   
   document.getElementById("Details").innerHTML = out;
}

function formatCountdown(varTime) {

   var dayLeft = varTime / msRealDay;
   var hourLeft = (dayLeft - Math.floor(dayLeft)) * 24;
   var minLeft = (hourLeft - Math.floor(hourLeft)) * 60;
   var secLeft = Math.floor((minLeft - Math.floor(minLeft)) * 60);
   var formattedTime = '';

   dayLeft = Math.floor(dayLeft);
   hourLeft = Math.floor(hourLeft);
   minLeft = Math.floor(minLeft);

   if (minLeft < 10) {minLeft = '0' + minLeft;}
   if (secLeft < 10) {secLeft = '0' + secLeft;}

   if (dayLeft > 0) {
      formattedTime = dayLeft + ':';
      if (hourLeft < 10) {
         formattedTime = formattedTime + '0' + hourLeft + ':';
      } else {
         formattedTime = formattedTime + hourLeft + ':';
      }        
   } else if (hourLeft > 0) {
      formattedTime = hourLeft + ':';
   }

   formattedTime = formattedTime + minLeft + ':' + secLeft;
   return formattedTime;
}

function formatDate(varTime, showDay) {

   var varDate = new Date(varTime);
   var yyyy = varDate.getYear();

   var mm = varDate.getMonth() + 1;
   if (mm < 10) { mm = "0" + mm; }

   var dd = varDate.getDate();
   if (dd < 10) { dd = "0" + dd; }

   var day = varDate.getDay();

   var hh = varDate.getHours();
   
   if (hh < 10) { hh = "0" + hh; }

   var min = varDate.getMinutes();
   if (min < 10) { min = "0" + min; }

   var ss = varDate.getSeconds();
   if (ss < 10) { ss = "0" + ss; }

   if (showDay == 1)  {
      dateString = EarthDay[day] + ", " + sMonth[mm-1] + ' ' + dd + ', ' + yyyy + " " + hh + ":" + min + ":" + ss;
   } else if (showDay == 2)  {
      dateString = sMonth[mm-1] + " " + dd + ",  " + hh + ":" + min + ":" + ss;
   }
   return dateString;
}

function printPage() {
   getVanadielTime();
   getEarthTime();
   getMoonPhase();
   getRSE();
   getConquest();
   getShipSched();
   getDaySched();
   getGuildHours();
   getAirSched();
   setTimeout("printPage()", 50);
}




// -->

Once again, thank you so much for your help.
~Skid
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I'll take a peek at the Java code and see if I can decipher it...
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Here is a port of the Java code:

Public Class Form1

    Private WithEvents tmr As New System.Windows.Forms.Timer()

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tmr.Interval = 40
        tmr.Start()
    End Sub

    Private Sub tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr.Tick
        Label1.Text = getVanadielTime()
    End Sub

    Private basisDate As New DateTime(2002, 6, 23, 15, 0, 0) ' 2002-06-23 @ 15:00:00.0000
    Private msRealDay As Long = TimeSpan.TicksPerDay / TimeSpan.TicksPerMillisecond ' milliseconds in a real day
    Private VanaDay() As String = {"Firesday", "Earthsday", "Watersday", "Windsday", "Iceday", "Lightningday", "Lightsday", "Darksday"}

    Private Function getVanadielTime() As String
        Dim vanaDate As Long = ((898 * 360 + 30) * msRealDay) + ((DateTime.UtcNow - basisDate).TotalMilliseconds * 25)
        Dim vYear As Integer = Math.Floor(vanaDate / (360 * msRealDay))
        Dim vMon As Integer = Math.Floor((vanaDate Mod (360 * msRealDay)) / (30 * msRealDay)) + 1
        Dim vDate As Integer = Math.Floor((vanaDate Mod (30 * msRealDay)) / (msRealDay)) + 1
        Dim vHour As Integer = Math.Floor((vanaDate Mod (msRealDay)) / (60 * 60 * 1000))
        Dim vMin As Integer = Math.Floor((vanaDate Mod (60 * 60 * 1000)) / (60 * 1000))
        Dim vSec As Integer = Math.Floor((vanaDate Mod (60 * 1000)) / 1000)
        Dim vDay As Integer = Math.Floor((vanaDate Mod (8 * msRealDay)) / (msRealDay))
        Return VanaDay(vDay) & ", " & vYear.ToString("0000") & "-" & vMon.ToString("00") & "-" _
            & vDate.ToString("00") & "  " & vHour.ToString("00") & ":" & vMin.ToString("00") & ":" _
            & vSec.ToString("00")
    End Function

End Class
0
 
SkidwizAuthor Commented:
Idle Mind,

You have made me a happy person indeed.  That works perfectly.  Thank you again for the time and effort you put into this.  You're amazing.  Thank you.

~Skid

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
It's alot easier converting someone elses code than trying to figure out the algorithm yourself.   ;)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now