Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions app/consapp/convbin/convbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,8 @@ static void setglofcn(const char *argv, rnxopt_t *opt) {
static int get_filetime(const char *file, gtime_t *time)
{
FILE *fp;
struct stat st;
struct tm *tm;
uint32_t time_time;
uint8_t buff[64];
double ep[6];
char path[1024],*paths[1],path_tag[1024];

paths[0]=path;
Expand All @@ -402,16 +399,21 @@ static int get_filetime(const char *file, gtime_t *time)
}
fclose(fp);
}
/* get modified time of input file */
if (!stat(path,&st)&&(tm=gmtime(&st.st_mtime))) {
ep[0]=tm->tm_year+1900;
ep[1]=tm->tm_mon+1;
ep[2]=tm->tm_mday;
ep[3]=tm->tm_hour;
ep[4]=tm->tm_min;
ep[5]=tm->tm_sec;
*time=utc2gpst(epoch2time(ep));
return 1;
/* Get modified time of input file. */
struct stat st;
if (!stat(path, &st)) {
struct tm tm;
if (gmtime_r(&st.st_mtime, &tm)) {
double ep[6];
ep[0] = tm.tm_year + 1900;
ep[1] = tm.tm_mon + 1;
ep[2] = tm.tm_mday;
ep[3] = tm.tm_hour;
ep[4] = tm.tm_min;
ep[5] = tm.tm_sec;
*time = utc2gpst(epoch2time(ep));
return 1;
}
}
return 0;
}
Expand Down
18 changes: 11 additions & 7 deletions src/rtkcmn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1784,7 +1784,6 @@ static double timeoffset_=0.0; /* time offset (s) */

extern gtime_t timeget(void)
{
gtime_t time;
double ep[6]={0};
#ifdef WIN32
SYSTEMTIME ts;
Expand All @@ -1794,14 +1793,19 @@ extern gtime_t timeget(void)
ep[3]=ts.wHour; ep[4]=ts.wMinute; ep[5]=ts.wSecond+ts.wMilliseconds*1E-3;
#else
struct timeval tv;
struct tm *tt;

if (!gettimeofday(&tv,NULL)&&(tt=gmtime(&tv.tv_sec))) {
ep[0]=tt->tm_year+1900; ep[1]=tt->tm_mon+1; ep[2]=tt->tm_mday;
ep[3]=tt->tm_hour; ep[4]=tt->tm_min; ep[5]=tt->tm_sec+tv.tv_usec*1E-6;
if (!gettimeofday(&tv, NULL)) {
struct tm tt;
if (gmtime_r(&tv.tv_sec, &tt)) {
ep[0] = tt.tm_year + 1900;
ep[1] = tt.tm_mon + 1;
ep[2] = tt.tm_mday;
ep[3] = tt.tm_hour;
ep[4] = tt.tm_min;
ep[5] = tt.tm_sec + tv.tv_usec * 1E-6;
}
}
#endif
time=epoch2time(ep);
gtime_t time = epoch2time(ep);

#ifdef CPUTIME_IN_GPST /* cputime operated in gpst */
time=gpst2utc(time);
Expand Down