//Copyright (C) 2007, 2010 by The.Modificator

// The basis for the length of one ages day is - according to
// the map and some other research - 13 Partavotí (NTS).
// HOWEVER, that number is just an approximation as it was found
// out. A more precise number is given below:

var POD_AGE_DAY_LENGTH=15.7180727392538; //updated 2010-02-13

var NEGILAHN_ZERO_DATE=2454163.272337963; //Julian Date: 2007-03-03 18:32:09,300 UTC

var NEGILAHN_TO_DERENO=0.051655092596775;
var NEGILAHN_TO_PAYIFEREN=0.075046296296932;
var NEGILAHN_TO_TETSONOT=0.189895833333139;



function getPodAgeDayLength()
{
	return POD_AGE_DAY_LENGTH;
}


// Universal Pod Age Time (UPT/0) calculation functions
// 
// Since we don't know the exact time at the
// Pod Age Date Line, we have to estimate it.
// To do so, we'll take Dereno Pod Time and
// add about 1.5/13 to it. (Reason: The map
// suggest to use such a number.)
function jd2universalpodtime(jd)
{
	return jd2dereno(jd)+1.5/13;
}

function universalpodtime2jd(universal)
{
	return dereno2jd(universal-1.5/13);
}


// Negilahn Time (UPT/N) calculation functions

function jd2negilahn(jd)
{
	return (jd-NEGILAHN_ZERO_DATE)/(POD_AGE_DAY_LENGTH/24);
}

function negilahn2jd(negilahn)
{
	return negilahn*(POD_AGE_DAY_LENGTH/24)+NEGILAHN_ZERO_DATE;
}


// Dereno Time (UPT/D) calculation functions
// 
// Take Negilahn Time as basis and shift it accordingly.
function jd2dereno(jd)
{
	return jd2negilahn(jd-NEGILAHN_TO_DERENO);
}

function dereno2jd(dereno)
{
	return negilahn2jd(dereno)+NEGILAHN_TO_DERENO;
}


// Payiferen (UPT/P) calculation functions
// 
// Take Negilahn Time as basis and shift it accordingly.
function jd2payiferen(jd)
{
	return jd2negilahn(jd-NEGILAHN_TO_PAYIFEREN);
}

function payiferen2jd(payiferen)
{
	return negilahn2jd(payiferen)+NEGILAHN_TO_PAYIFEREN;
}


// Tetsonot (UPT/T) calculation functions
// 
// Take Negilahn Time as basis and shift it accordingly.
function jd2tetsonot(jd)
{
	return jd2negilahn(jd-NEGILAHN_TO_TETSONOT);
}

function tetsonot2jd(tetsonot)
{
	return negilahn2jd(tetsonot)+NEGILAHN_TO_TETSONOT;
}
