OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
timediff.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

Go to the source code of this file.

Macros

#define _FCALL

Functions

void strptime_impl (char *date, struct tm *tm)
void c_time_difference (char *time_string, int *time_string_len, int *difference)
void c_time_difference_ (char *time_string, int *time_string_len, int *difference)
void _FCALL C_TIME_DIFFERENCE (char *time_string, int *time_string_len, int *difference)

Macro Definition Documentation

◆ _FCALL

#define _FCALL

Definition at line 26 of file timediff.c.

Function Documentation

◆ C_TIME_DIFFERENCE()

void _FCALL C_TIME_DIFFERENCE ( char * time_string,
int * time_string_len,
int * difference )

Definition at line 83 of file timediff.c.

83 {
84 c_time_difference(time_string,time_string_len, difference);
85}
void c_time_difference(char *time_string, int *time_string_len, int *difference)
Definition timediff.c:38

◆ c_time_difference()

void c_time_difference ( char * time_string,
int * time_string_len,
int * difference )

Definition at line 38 of file timediff.c.

39{
40 char * c_time_string;
41 int i;
42 time_t now,now_utc,dummy_time;
43 double tdiff;
44 struct tm *tm_dum,*tm_now;
45 char datestring[32], curtime[32];
46
47 c_time_string = malloc(*time_string_len+1);
48 for (i=0;i<*time_string_len;i++) c_time_string[i]=time_string[i];
49 c_time_string[*time_string_len]='\0';
50
51
52/* Current Time in UTC */
53 time( &now );
54 strftime(datestring, 32, "%Y-%m-%dT%H:%M:%S", gmtime( &now ));
55 tm_now = (struct tm*)malloc(sizeof (struct tm));
56 strptime_impl(datestring,tm_now);
57 now_utc=mktime(tm_now);
58
59/* convert time in header*/
60 tm_dum = malloc(sizeof (struct tm));
61 strptime_impl(c_time_string,tm_dum);
62 dummy_time= mktime(tm_dum);
63 tdiff=difftime(dummy_time,now_utc);
64
65 if (tdiff > 0 ){
66 * difference = 1;
67 }else{
68 * difference = -1;
69
70 }
71// *difference=(int) tdiff;
72// printf("c_time_string: %s\n",c_time_string);
73// printf("Datestring : %s\n",datestring);
74// printf("DIFFERENCE: %lf \n",tdiff);
75// printf("Integer difference: %i \n", * difference);
76// fflush(stdout);
77}
void strptime_impl(char *date, struct tm *tm)
Definition timediff.c:87

◆ c_time_difference_()

void c_time_difference_ ( char * time_string,
int * time_string_len,
int * difference )

Definition at line 79 of file timediff.c.

79 {
80 c_time_difference(time_string,time_string_len, difference);
81}

◆ strptime_impl()

void strptime_impl ( char * date,
struct tm * tm )

Definition at line 87 of file timediff.c.

88{
89 int year, month, day, hour, min, sec ;
90
91 memset(tm,0,sizeof(struct tm));
92
93 sscanf(date,"%d-%d-%dT%d:%d:%d",&year,&month,&day,&hour,&min,&sec );
94 tm->tm_year = year - 1900;
95 tm->tm_mon = month-1;
96 tm->tm_mday = day;
97 tm->tm_hour = hour;
98 tm->tm_min = min;
99 tm->tm_sec = sec;
100
101}
#define min(a, b)
Definition macros.h:20