/*
 * conversions.js, dominic watson, 29th June 2009
 * heap of functions for converting stuff 
 */

// temperature
function celciusToFahrenheit(celcius){
	return (9 / 5) * celcius + 32;
}
function fahrenheitToCelcius(fahrenheit){
	return (5 / 9) * (fahrenheit - 32);
}

// grams & oz
function gramsToOunces(grams){
	return grams * 0.03527;
}
function ouncesToGrams(oz){
	return oz * 28.41;
}

// grams and lbs
function gramsToPounds(grams){
	return grams * 0.002204;
}
function poundsToGrams(lbs){
	return lbs * 453.6;
}

// ml and fluid ounces
function mlToFluidOunces(ml){
	return ml * 0.0352;
}
function fluidOuncesToMl(oz){
	return oz * 28.409;
}

// oz and pints
function fluidOuncesToPints(oz){
	return oz * 0.05;
}
function pintsToFluidOunces(pints){
	return pints * 20;
}

// oz and teaspoons
function fluidOuncesToTeaspoons(oz){
	return mlToTeaspoons( fluidOuncesToMl(oz) );
}
function teaspoonsToFluidOunces(ts){
	return mlToFluidOunces( teaspoonsToMl(ts) );
}

// oz and tablespoons
function fluidOuncesToTablespoons(oz){
	return mlToTablespoons( fluidOuncesToMl(oz) );
}
function tablespoonsToFluidOunces(ts){
	return mlToFluidOunces( tablespoonsToMl(ts) );
}

// spoons
function teaspoonsToTablespoons(ts){
	return ts * (1 / 3);
}
function tablespoonsToTeaspoons(ts){
	return ts * 3;
}

// litres and millilitres
function litresToMl(l){
	return l * 1000;
}
function mlToLitres(ml){
	return ml * 0.001;
} 

// kilograms and grams
function kilogramsToGrams(kg){
	return kg * 1000;
}
function gramsToKilograms(g){
	return g * 0.001;
}

// pints and millilitres
function pintsToMl(p){
	return p * 568.26;
}
function mlToPints(ml){
	return ml *  0.00175;
}

// teaspoons and millilitres
function teaspoonsToMl(ts){
	return ts * 5;
}
function mlToTeaspoons(ml){
	return ml *  0.2;
}

// tablespoons and millilitres
function tablespoonsToMl(ts){
	return ts * 15;
}
function mlToTablespoons(ml){
	return ml * (1 / 15);
}

// teaspoons and pints
function teaspoonsToPints(ts){
	return mlToPints( teaspoonsToMl(ts) );
}
function pintsToTeaspoons(p){
	return mlToTeaspoons( pintsToMl(p) );
}

// tablespoons and pints
function tablespoonsToPints(ts){
	return mlToPints( tablespoonsToMl(ts) );
}
function pintsToTablespoons(p){
	return mlToTablespoons( pintsToMl(p) );
}