En el archivo changelog de nuestra aplicación la fecha tiene este formato:
* Tue Jul 25 2017 postapase <uno.cero@live.com> 0.6.320
* Mon Jul 17 2017 postapase <uno.cero@live.com> 0.6.319
* Fri Jul 07 2017 postapase <uno.cero@live.com> 0.6.318
* Sun Jun 11 2017 postapase <uno.cero@live.com> 0.6.3
* Tue Jun 11 2017 postapase <uno.cero@live.com> 0.6.3
en mi caso en VisorRV1960 muestro el archivo changelog para que la gente vea la historia o evolución de la aplicación, pero la fecha en ingles no pega y quería dejarla en español y con otro formato, específicamente con este
( "dddd dd mmmm yyyy" = jueves 28 mayo 2015)
Para eso cree un formulario que solo ejecuta esa tarea.
El resultado queda así:
* martes 25 julio 2017 postapase <uno.cero@live.com> 0.6.320
* lunes 17 julio 2017 postapase <uno.cero@live.com> 0.6.319
* viernes 07 julio 2017 postapase <uno.cero@live.com> 0.6.318
* domingo 11 junio 2017 postapase <uno.cero@live.com> 0.6.3
* domingo 11 junio 2017 postapase <uno.cero@live.com> 0.6.3
Aquí les dejo el código para que puedan usarlo y modificarlo a gusto teniendo ya el 70% del trabajo hecho jaja:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Gambas class file | |
Public Sub Form_Open() | |
End | |
Public Sub Traducir() | |
Dim archivo As File | |
Dim a As Integer | |
Dim linea, NuevaLinea, textos, NuevoTexto, ruta As String | |
Dim FechaOptenida As Date | |
archivo = Open ".hidden/CHANGELOG" For Read | |
While Not Eof(archivo) | |
Line Input #archivo, linea | |
If linea Begins "*" Then | |
FechaOptenida = ObtenerFecha(Left(linea, 17)) | |
NuevoTexto = FormatoFecha("dddd dd mmmm yyyy", FechaOptenida) | |
NuevaLinea = Replace(linea, Left(linea, 17), "* " & NuevoTexto) | |
textos = NuevaLinea | |
Else | |
textos = linea | |
Endif | |
TextArea1.Text &= textos & gb.NewLine | |
Wait 0.001 | |
Wend | |
Close #archivo | |
ruta = Application.Path &/ "textos/Historial" | |
File.Save(ruta, TextArea1.Text) | |
Catch | |
Print Error.Text | |
Print Error.Where | |
Print Error.Code | |
End | |
Private Sub ObtenerFecha(texto As String) As Date | |
Dim corte As String[] | |
corte = Split(texto, " ") | |
Return CDate(QueMes(corte[2]) & "/" & corte[3] & "/" & corte[4]) | |
End | |
Private Sub QueMes(texto As String) As Integer | |
Select Case texto | |
Case "Jan" | |
Return 1 | |
Case "Feb" | |
Return 2 | |
Case "Mar" | |
Return 3 | |
Case "Apr" | |
Return 4 | |
Case "May" | |
Return 5 | |
Case "Jun" | |
Return 6 | |
Case "Jul" | |
Return 7 | |
Case "Aug" | |
Return 8 | |
Case "Sep" | |
Return 9 | |
Case "Oct" | |
Return 10 | |
Case "Nov" | |
Return 11 | |
Case "Dec" | |
Return 12 | |
End Select | |
End | |
Private Sub FormatoFecha(formato As String, fecha As Date) As String | |
Return Format(fecha, formato) | |
End | |
Public Sub btnTraducir_Click() | |
Traducir() | |
End |