Last active
August 26, 2021 20:21
-
-
Save ScratchyCode/4518d656ea2fc36f148e9b4be01a76f7 to your computer and use it in GitHub Desktop.
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
// Coded by Scratchy | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
void scadenzaCheck(void); | |
int main(void){ | |
scadenzaCheck(); | |
printf("MESSAGGIO:\nDisse il verme alla noce: 'dammi tempo che ti buco'.\n\n"); | |
system("pause"); | |
return 0; | |
} | |
void scadenzaCheck(void){ | |
unsigned int set_epoch; | |
struct tm t; | |
time_t t_of_day; | |
// set data scadenza | |
t.tm_mday = 2; // giorno del mese | |
t.tm_mon = 7 - 1; // numero del mese meno 1, perchè 0 = gennaio | |
t.tm_year = 2021 - 1900; // anno - 1900 | |
t.tm_hour = 21; | |
t.tm_min = 30; | |
t.tm_sec = 0; | |
t.tm_isdst = -1; // E' attivo il DST? 1 = si, 0 = no, -1 = sconosciuto | |
t_of_day = mktime(&t); | |
set_epoch = (long)(t_of_day); | |
// check data scadenza eseguibile | |
if(time(0) >= set_epoch){ | |
// data invalida, if per formattare l'output | |
if(t.tm_min <= 9){ | |
printf("Impossibile eseguire: programma scaduto nel %d/%d/%d alle %d:%d%d!\n\n",t.tm_mday,t.tm_mon + 1,t.tm_year + 1900,t.tm_hour,0,t.tm_min); | |
}else{ | |
printf("Impossibile eseguire: programma scaduto nel %d/%d/%d alle %d:%d!\n\n",t.tm_mday,t.tm_mon + 1,t.tm_year + 1900,t.tm_hour,t.tm_min); | |
} | |
system("pause"); | |
exit(0); | |
}else{ | |
// data valida, if per formattare l'output | |
if(t.tm_min <= 9){ | |
printf("Esecuzione consentita!\nData di scadenza: %d/%d/%d ore %d:%d%d\n\n",t.tm_mday,t.tm_mon + 1,t.tm_year + 1900,t.tm_hour,0,t.tm_min); | |
}else{ | |
printf("Esecuzione consentita!\nData di scadenza: %d/%d/%d ore %d:%d\n\n",t.tm_mday,t.tm_mon + 1,t.tm_year + 1900,t.tm_hour,t.tm_min); | |
} | |
printf("Tempo mancante:\n%.2lf giorni\n%.2lf ore\n%.2lf minuti\n%.0lf secondi\n\n",(((double)(set_epoch-time(0))/60)/60)/24,((double)(set_epoch-time(0))/60)/60,(double)(set_epoch-time(0))/60,(double)(set_epoch-time(0))); | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment