Skip to content

Instantly share code, notes, and snippets.

@juananruiz
Created February 4, 2014 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juananruiz/8806749 to your computer and use it in GitHub Desktop.
Save juananruiz/8806749 to your computer and use it in GitHub Desktop.
<?php
$entrada = fopen("asistencia.csv", "r");
$salida = fopen("asistencia_procesada.csv", "w");
while (($line = fgetcsv($entrada, 1000, ";")) !== FALSE)
{
if ($line[3] == '0:00')
{
$hora_fin_exploded = explode(":", $line[4]);
$hora_fin = $hora_fin_exploded[0];
$minuto_fin = $hora_fin_exploded[1];
$fecha_original = $line[2];
$fecha_exploded = explode("/", $line[2]);
while ($hora_fin > 7)
{
$line[4] = '07:00';
if ($fecha_exploded[0] > 1)
{
$fecha_exploded[0] --;
}
else
{
$fecha_exploded[0] = 28;
}
if ($fecha_exploded[0] < 10)
{
$fecha_exploded[0] = "0" . $fecha_exploded[0];
}
$line[2] = implode("/", $fecha_exploded);
fputcsv($salida, $line);
$hora_fin -= 7;
}
$line[2] = $fecha_original;
$line[4] = '0' . $hora_fin . ':' . $minuto_fin;
fputcsv($salida, $line);
}
else
{
fputcsv($salida, $line);
}
}
fclose($salida);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment