Re: localtime question

2004-08-11 Thread Giorgos Keramidas
On 2004-08-11 12:23, Mipam <[EMAIL PROTECTED]> wrote: > On Wed, 11 Aug 2004, Giorgos Keramidas wrote: > > On 2004-08-11 10:44, Mipam <[EMAIL PROTECTED]> wrote: > > > #include > > > #include > > > > > > int main() > > > { > > > struct tm *ptr; > > > time_t tm; > > > char str[60]; > > >

Re: localtime question

2004-08-11 Thread Mipam
On Wed, 11 Aug 2004, Giorgos Keramidas wrote: > On 2004-08-11 10:44, Mipam <[EMAIL PROTECTED]> wrote: > > > You'd have to use strftime() and a local buffer for that. > > > > I found an example and adjusted it: > > > > #include > > #include > > > > int main() > > { > > struct tm *ptr; > >

Re: localtime question

2004-08-11 Thread Giorgos Keramidas
On 2004-08-11 10:44, Mipam <[EMAIL PROTECTED]> wrote: > > You'd have to use strftime() and a local buffer for that. > > I found an example and adjusted it: > > #include > #include > > int main() > { > struct tm *ptr; > time_t tm; > char str[60]; > char str2[60]; > char str3[60

Re: localtime question

2004-08-11 Thread Mipam
[SNIP] > You'd have to use strftime() and a local buffer for that. I found an example and adjusted it: #include #include int main() { struct tm *ptr; time_t tm; char str[60]; char str2[60]; char str3[60]; tm = time(NULL)-86400; ptr = localtime(&tm); strftime(str ,100 , "%d",ptr); strftime(st

Re: localtime question

2004-08-10 Thread Mipam
On Tue, 10 Aug 2004, Giorgos Keramidas wrote: > On 2004-08-10 18:45, Mipam <[EMAIL PROTECTED]> wrote: > > #include > > #include > > > > int main(void) > > { > > struct timeval tv; > > struct timeval tv_current; > > if (gettimeofday(&tv_current, NULL) == -1) > >err(1, "Could not get local tim

Re: localtime question

2004-08-10 Thread Giorgos Keramidas
On 2004-08-10 18:45, Mipam <[EMAIL PROTECTED]> wrote: > #include > #include > > int main(void) > { > struct timeval tv; > struct timeval tv_current; > if (gettimeofday(&tv_current, NULL) == -1) >err(1, "Could not get local time of day"); > tv.tv_sec = tv_current.tv_sec-86400; > printf("%s\n",

Re: localtime question

2004-08-10 Thread Giorgos Keramidas
On 2004-08-10 18:45, Mipam <[EMAIL PROTECTED]> wrote: > > Try calling ctime() with the address of tv.tv_sec: > > > > printf("%s\n", ctime(&tv.tv_sec)); > > #include > #include > > int main(void) > { > struct timeval tv; > struct timeval tv_current; > if (gettimeofday(&tv_current, NULL) ==

Re: localtime question

2004-08-10 Thread Mipam
> Note that it's a good idea to explicitly specify that main() does > nothing to its argument with: > > int > main(void) > { > ... > } > > and that main() has to `return' some value that fits in an `int' as its > definition says it should. > > > Bu

Re: localtime question

2004-08-10 Thread Giorgos Keramidas
On 2004-08-10 16:49, Mipam <[EMAIL PROTECTED]> wrote: > Hi, > > I tried to display the time from yesterday by this little program > > #include > #include > > time_t tval; > > int main() > { > struct timeval tv; > struct timeval tv_current; > > if (gettimeofday(&tv_current, NULL) == -1