ASP: Convert Temperature (Fahrenheit & Celcius)
Introduction
Author: Martin WarningYear: 2008
License: Free
These functions are useful if you have temperature data in one temperature system and need to convert them to another.
Code
Languages:- ASP
- VBScript
<% ' Function to convert Fahrenheit to Celsius Function fncFahrenheitToCelsius(intF) If isNumeric(intF) Then fncFahrenheitToCelsius = formatNumber((5/9)*(intF-32),2) & " °C" End If End Function %>
Example: See it in action
This code will only convert a date send to it to a RSS compatible date. You would call this function like fncRSSDate(Now()) to get the RSS variant of in this case the current time (at page load).
The following code is an example function to convert Celsius to Fahrenheit:
<% ' Function to convert Celsius to Fahrenheit Function fncCelsiusToFahrenheit(intC) If isNumeric(intC) Then fncCelsiusToFahrenheit = formatNumber(((9*intC)/5) + 32,2) & " °F" End If End Function %>The formatNumber allows us to limit the ammount of decimals shown. It takes 2 values, the first being the number you want to modify and the second value the ammount of decimal places that should be shown, which is 2 in the examples case.
