September 17, 2007

Vana'diel Time in C# (Vana'diel Crazy Taru Clock) ヴァナ・ディール ☆基地外 たる 時計☆

ヴァナ・ディール ☆基地外 たる 時計☆
Vana'diel Crazy Taru Clock

I was bored , so decided to port the Pyogenes "Vana'diel Time" Clock to C#
About:
Vana'diel time is 25 times faster than Earth time and is being used in the fictional? universe of Final Fantasy XI Online


I made a simple API that you can use to get current weather in Vana'diel, that means you can use it in any application you want, everything from Command Line Applications, to AJAX Powered ASP.NET websites, remember, you have to use Timer.Tick() to update the information from the API! Or you can implement it directly to the class, if you want to; do whatever you want with it, just remember to credit me and Pyogenes for his great formula.

Note this is the first implementation of Vana'diel clock in C# , if I'm wrong , someone correct me...

Here goes the code (Sorry, no comments (yet), I'm sleepy):

using System;
using System.Collections.Generic;
using System.Text;
namespace Animaonline.Vanadiel
{
public static class Time
{
private static DateTime basisDate = new DateTime(2002, 06, 23, 15, 00, 00, 0000);
private static long msRealDay = 86400000;
private static string[] VanaDay = { "Firesday", "Earthsday", "Watersday", "Windsday", "Iceday", "Lightningday", "Lightsday", "Darksday" };
private static double vanaDate
{
get { return ((898 * 360 + 30) * msRealDay) + ((DateTime.UtcNow - basisDate).TotalMilliseconds * 25); }
}
public static double vYear
{
get { return Math.Floor(vanaDate / (360 * msRealDay)); }
}
public static double vMon
{
get { return Math.Floor((vanaDate % (360 * msRealDay)) / (30 * msRealDay)) + 1; }
}
public static double vDate
{
get { return Math.Floor((vanaDate % (30 * msRealDay)) / (msRealDay)) + 1; }
}
public static double vHour
{
get { return Math.Floor((vanaDate % (msRealDay)) / (60 * 60 * 1000)); }
}
public static double vMin
{
get { return Math.Floor((vanaDate % (60 * 60 * 1000)) / (60 * 1000)); }
}
public static double vSec
{
get { return Math.Floor((vanaDate % (60 * 1000)) / 1000); }
}
public static double vDay
{
get { return Math.Floor((vanaDate % (8 * msRealDay)) / (msRealDay)); }
}
public static string TextTime = vMon + "/" + vDate + "/" + vYear + " (" + VanaDay[Convert.ToInt16(vDay)] + ") " + vHour + ":" + vMin + ":" + vSec;
}
}

Usage: To use the code in your application just create a new class and paste the code (you can also compile it into a dll, and share it with your friends, if you want to)

In your application's main void or click event or whatever write the following code:

MessageBox.Show(Animaonline.Vanadiel.Time.vHour + ":" + Animaonline.Vanadiel.Time.vMin + ":" + Animaonline.Vanadiel.Time.vSec);

That's it, enjoy! :D


Back to Home

1 comment:

  1. Awesome! This was exactly what I was looking for.

    ReplyDelete

Note: Only a member of this blog may post a comment.