Re: Get local date / hour
- From: Bob Caryl <bob fis-cal com>
- To: Mickael Drean <mickael drean gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Get local date / hour
- Date: Mon, 13 Mar 2006 16:17:47 -0600
Mickael Drean wrote:
Hi there,
Is there a way to easily get date and hour of the local computer ?
bye
------------------------------------------------------------------------
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
Please be advised that your question is off topic for this list;
nevertheless, below is a function that formats the current time from
the computer and returns a char pointer to a string containing that time:
#include <stdio.h>
#include <time.h>
#include <memory.h>
char *get_time(boolean doseconds)
{
time_t lt;
int retval;
struct tm *tm;
static char locbuf[9];
/* clean up buffer */
memset((void *)locbuf,0,sizeof(locbuf));
/* generate time structure */
lt = time(NULL);
tm = localtime(<);
if(doseconds)
sprintf(locbuf,"%02d%02d%02d",tm->tm_hour,tm->tm_min,tm->tm_sec);
else
sprintf(locbuf,"%02d%02d",tm->tm_hour,tm->tm_min);
return locbuf;
}
Bob Caryl
begin:vcard
fn:Robert Caryl
n:Caryl;Robert
org:Fiscal Systems, Inc.
adr:;;102 Commerce Circle;Madison;AL;35758;USA
email;internet:bob fis-cal com
title:Senior Software Design Engineer
tel;work:356-772-8920 X108
x-mozilla-html:TRUE
url:http://www.fis-cal.com
version:2.1
end:vcard
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]