' 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