ASP: Name Of Day And Month Functions For Foreign Languages


Introduction

Author: Martin Warning
Year: 2007
License: Free

ASP has built in methods to get the name of the day and the name of the month. For day you would use WeekdayName(WeekDay(date())) and for month you would use MonthName(date()). The only issue with these methods is that the day and month are displayed in English. If your site requires another language you will need to create a function to get the day name and month name in your local language.

The following functions are able to get the name of the day and the name of the month. They are 2 separated functions so you can implement it any form needed on your site. The example funcions will get the day and month name in Spanish.

Code

Languages: The following code is an example function to get the name of the day:
<%
' Function to get the day name of a day of the week
	' Requires to have the day of the week number passed to the function

Function fncDayName(intDay)

	Dim strDay

	Select Case intDay
		Case 1
			strDay = "Domingo"
		Case 2
			strDay = "Lunes"
		Case 3
			strDay = "Martes"
		Case 4
			strDay = "Miercoles"
		Case 5
			strDay = "Jueves"
		Case 6
			strDay = "Viernes"
		Case 7
			strDay = "Sabado"
		End Select

	fncDayName = strDay

End Function
%>

The following code is an example function to get the name of the month:
<%
' Function to get the month name of a month
	' Requires to have the month number passed to the function

Function fncMonthName(intMonth)

	Dim strMonth

	Select Case intMonth
		Case 1
			strMonth = "Enero"
		Case 2
			strMonth = "Febrero"
		Case 3
			strMonth = "Marzo"
		Case 4
			strMonth = "Abril"
		Case 5
			strMonth = "Mayo"
		Case 6
			strMonth = "Junio"
		Case 7
			strMonth = "Julio"
		Case 8
			strMonth = "Agosto"
		Case 9
			strMonth = "Septiembre"
		Case 10
			strMonth = "Octubre"
		Case 11
			strMonth = "Noviembre"
		Case 12
			strMonth = "Diciembre"
	End Select

	fncMonthName = strMonth

End Function
%>



Printed from: http://flyinglowlander.com/ (5/20/2012)
© FlyingLowander.com 2006 - 2012

Visit http://flyinglowlander.com for more XHTML, CSS, ASP and JavaScript examples, templates and tutorials.