Devi restituire un double la cui parte intera siano i giorni trascorsi dal 1 gennaio 1900, dove 1.0 rappresenta la mezzanotte del primo gennaio 1900, e la parte decimale rappresenta la frazione di un giorno, ad esempio 1.5 rappresenta mezzogiorno del 1 genn. 1900.
esempio
codice:
double __stdcall tempoUTC()
{
time_t t = time(NULL);
return (double)(25569 + t / 86400) + (double)(t % 86400) / 86400.0;
}
double __stdcall tempoLoc()
{
time_t now = time(NULL);
struct tm* t = localtime(&now);
return (double)
(1 + t->tm_year * 365 +
(t->tm_year + 4)/ 4 -
(t->tm_year) / 100 +
(t->tm_year + 300) / 400 +
t->tm_yday
) +
(double)
(t->tm_hour * 3600 + t->tm_min*60+t->tm_sec) / 86400.0;
}
VB
codice:
Private Declare Function tempoUTC Lib "VbLib" () As Date
Private Declare Function tempoLoc Lib "VbLib" () As Date