Re: Get local date / hour



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(&lt);
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]