/*
*************************************************************
* @file gocheck.c
* Compilacion: cc -c gocheck.c -o gocheck.o -w
* LinkEdicion: cc -o gocheck gocheck.o -w
* ***********************************************
* Comp&Linker:
cc -o gocheck gocheck.c
* autor: ElVino.Falta(farfan890@gmail.com)
* @brief detecta la fecha de una archivo
*************************************************************
*/
#include <time.h>
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#define TRUE 1
#define FALSE 0
int main( int argc, char* argv[] ) {
char file[] = "ArvhivodeHoy.txt";
char tmFile[ 100 ] = "";
char tmFile_Fecha[ 10 ] = "";
char tmFile_Hora[ 6 ] = "";
char tmHoy[ 100 ] = "";
char tmHoy_Fecha[ 10 ] = "";
char tmHoy_Hora[ 6 ] = "";
struct stat b;
time_t tToday = time(NULL);
/*
strftime(tmHoy, 100, "%d/%m/%Y %H:%M:%S", localtime( &tToday));
strftime(tmHoy_Fecha, 10, "%Y%m%d ", localtime( &tToday));
strftime(tmHoy_Hora, 6, "%H%M", localtime( &tToday));
printf("\nFecha y Hora, Hoy = %s\n", tmHoy); printf("\nFecha %s y Hora %s de Hoy\n", tmHoy_Fecha, tmHoy_Hora); */
while(TRUE) {
tToday = time(NULL);
strftime(tmHoy, 100, "%d/%m/%Y %H:%M:%S", localtime( &tToday));
strftime(tmHoy_Fecha, 10, "%Y%m%d ", localtime( &tToday));
strftime(tmHoy_Hora, 6, "%H%M", localtime( &tToday));
printf("\nFecha y Hora, Hoy = %s\n", tmHoy); printf("\nFecha %s y Hora %s de Hoy\n", tmHoy_Fecha, tmHoy_Hora); if (!stat(file, &b)) { strftime(tmFile, 100, "%d/%m/%Y %H:%M:%S", localtime( &b.st_mtime));
strftime(tmFile_Fecha, 10, "%Y%m%d ", localtime( &b.st_mtime));
strftime(tmFile_Hora, 6, "%H%M", localtime( &b.st_mtime));
printf("\nUltima Modificacion = %s\n", tmFile); printf("\nFecha %s y Hora %s del Archivo\n", tmFile_Fecha, tmFile_Hora);
if( strcmp(tmHoy_Fecha, tmFile_Fecha) == 0) { printf("\nEl Archivo tiene fecha de Hoy... %s\n", tmFile_Fecha); if (atoi(tmFile_Hora) > 1730) { printf("\nY se genero despues de la 17:30 %s\n", tmFile_Hora); break;
} else
printf("\nY es anterior a las 17:30 %s \n", tmFile_Hora); }
} else { printf("No existe aun el Archivo\n"); }
sleep(5);
}
return 0;
}