blob: 33f3b2ee2350835d4f0717887be7754c608aaee4 [file] [log] [blame]
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/time.h>
#include <time.h>
#include <assert.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <ccn/ccn.h>
#include <ccn/uri.h>
#include <ccn/keystore.h>
#include <ccn/signing.h>
#include <ccn/schedule.h>
#include <ccn/hashtb.h>
#include "utility.h"
char * getLocalTimeStamp(void)
{
char *timestamp = (char *)malloc(sizeof(char) * 16);
time_t ltime;
ltime=time(NULL);
struct tm *tm;
tm=localtime(&ltime);
sprintf(timestamp, "%04d%02d%02d%02d%02d%02d", tm->tm_year+1900, tm->tm_mon+1,
tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
return timestamp;
}
char * getGmTimeStamp(void)
{
char *timestamp = (char *)malloc(sizeof(char) * 16);
time_t gtime;
gtime=time(NULL);
struct tm *tm;
tm=gmtime(&gtime);
sprintf(timestamp, "%04d%02d%02d%02d%02d%02d", tm->tm_year+1900, tm->tm_mon+1,
tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
return timestamp;
}
long int
get_current_time_sec(void)
{
struct timeval now;
gettimeofday(&now,NULL);
return now.tv_sec;
}
void
get_current_timestamp_micro(char * microSec)
{
struct timeval now;
gettimeofday(&now, NULL);
//char *microSec=(char *)malloc(20);
sprintf(microSec,"%ld%06ld",now.tv_sec,(long int)now.tv_usec);
//microSec[strlen(microSec)]='\0';
//return microSec;
}