Ver Mensaje Individual
  #122 (permalink)  
Antiguo 17/09/2011, 05:59
DanielImago
 
Fecha de Ingreso: septiembre-2011
Mensajes: 8
Antigüedad: 12 años, 7 meses
Puntos: 0
Respuesta: Biblioteca de Clases,Funciones y Sub-rutinas.

yo tengo un asp con un monton de funciones para cosas comunes que ASP no tiene... Paso algunas para fechas:

'
'Funciones de Fecha
'
Function FormatFecha(Fecha, Formato)
If IsDate(Fecha) Then
tmpFormatFecha = Formato
tmpFormatFecha = Replace(tmpFormatFecha, "hh", Right("0" & Hour(Fecha), 2))
tmpFormatFecha = Replace(tmpFormatFecha, "nn", Right("0" & Minute(Fecha), 2))
tmpFormatFecha = Replace(tmpFormatFecha, "ss", Right("0" & Second(Fecha), 2))
tmpFormatFecha = Replace(tmpFormatFecha, "yyyy", Year(Fecha))
tmpFormatFecha = Replace(tmpFormatFecha, "yy", Right(Year(Fecha), 2))
tmpFormatFecha = Replace(tmpFormatFecha, "mmmm", MesLLargo(Fecha))
tmpFormatFecha = Replace(tmpFormatFecha, "mmm", MesLCorto(Fecha))
tmpFormatFecha = Replace(tmpFormatFecha, "mm", Right("0" & Month(Fecha), 2))
tmpFormatFecha = Replace(tmpFormatFecha, "ddddd", DiaSLargoMay(Fecha))
tmpFormatFecha = Replace(tmpFormatFecha, "dddd", DiaSLargo(Fecha))
tmpFormatFecha = Replace(tmpFormatFecha, "ddd", DiaSCorto(Fecha))
tmpFormatFecha = Replace(tmpFormatFecha, "dd", Right("0" & Day(Fecha), 2))
FormatFecha = tmpFormatFecha
End IF
End Function

Function MesLLargo(Fecha)
Select Case Month(Fecha)
Case 1: MesLLargo = "Enero"
Case 2: MesLLargo = "Febrero"
Case 3: MesLLargo = "Marzo"
Case 4: MesLLargo = "Abril"
Case 5: MesLLargo = "Mayo"
Case 6: MesLLargo = "Junio"
Case 7: MesLLargo = "Julio"
Case 8: MesLLargo = "Agosto"
Case 9: MesLLargo = "Septiembre"
Case 10: MesLLargo = "Octubre"
Case 11: MesLLargo = "Noviembre"
Case 12: MesLLargo = "Diciembre"
End Select
End Function

Function MesLCorto(Fecha)
Select Case Month(Fecha)
Case 1: MesLCorto = "Ene"
Case 2: MesLCorto = "Feb"
Case 3: MesLCorto = "Mar"
Case 4: MesLCorto = "Abr"
Case 5: MesLCorto = "May"
Case 6: MesLCorto = "Jun"
Case 7: MesLCorto = "Jul"
Case 8: MesLCorto = "Ago"
Case 9: MesLCorto = "Sep"
Case 10: MesLCorto = "Oct"
Case 11: MesLCorto = "Nov"
Case 12: MesLCorto = "Dic"
End Select
End Function

Function DiaSLargo(Fecha)
Select Case WeekDay(Fecha)
Case 1: DiaSLargo = "Domingo"
Case 2: DiaSLargo = "Lunes"
Case 3: DiaSLargo = "Martes"
Case 4: DiaSLargo = "Miercoles"
Case 5: DiaSLargo = "Jueves"
Case 6: DiaSLargo = "Viernes"
Case 7: DiaSLargo = "Sabado"
End Select
End Function

Function DiaSLargoMay(Fecha)
Select Case WeekDay(Fecha)
Case 1: DiaSLargoMay = "<b>DOMINGO</b>"
Case 2: DiaSLargoMay = "<b>LUNES</b>"
Case 3: DiaSLargoMay = "<b>MARTES</b>"
Case 4: DiaSLargoMay = "<b>MIÉRCOLES</b>"
Case 5: DiaSLargoMay = "<b>JUEVES</b>"
Case 6: DiaSLargoMay = "<b>VIERNES</b>"
Case 7: DiaSLargoMay = "<b>SABADO</b>"
End Select
End Function

Function DiaSCorto(Fecha)
Select Case WeekDay(Fecha)
Case 1: DiaSCorto = "Dom"
Case 2: DiaSCorto = "Lun"
Case 3: DiaSCorto = "Mar"
Case 4: DiaSCorto = "Mie"
Case 5: DiaSCorto = "Jue"
Case 6: DiaSCorto = "Vie"
Case 7: DiaSCorto = "Sab"
End Select
End Function

Function ComboAnios(Anio_Inicio, Anio_Fin, Anio_default)
str_ComboAnios = ""
For t_ComboAnios = Anio_Inicio To Anio_Fin
strSelected = ""
If Anio_default = 0 Then
If Year(Now) = t_ComboAnios Then strSelected = "selected"
Else
If Anio_default = t_ComboAnios Then strSelected = "selected"
End IF
str_ComboAnios = str_ComboAnios & "<OPTION " & strSelected & " Value=" & t_ComboAnios & ">" & t_ComboAnios & "</OPTION>"
Next
ComboAnios = str_ComboAnios
End Function

Function ComboMeses(Mes_default)
str_ComboMes = ""
For t_ComboMes = 1 To 12
strSelected = ""
If Mes_default = 0 Then
If Month(Now) = t_ComboMes Then strSelected = "selected"
Else
If Mes_default = t_ComboMes Then strSelected = "selected"
End IF
str_ComboMes = str_ComboMes & "<OPTION " & strSelected & " Value=" & t_ComboMes & ">" & MesLLargo("01/" & t_ComboMes & "/2000") & "</OPTION>"
Next
ComboMeses = str_ComboMes
End Function

Function ComboDias(Dia_default)
str_ComboDia = ""
For t_ComboDia = 1 To 31
strSelected = ""
If Dia_default = 0 Then
If Day(Now) = t_ComboDia Then strSelected = "selected"
Else
If Dia_default = t_ComboDia Then strSelected = "selected"
End IF
str_ComboDia = str_ComboDia & "<OPTION " & strSelected & " Value=" & t_ComboDia & ">" & t_ComboDia & "</OPTION>"
Next
ComboDias = str_ComboDia
End Function