edmiRemoteGetDate

EdmiError edmiRemoteGetDate(SdaiServerContext serverContextId,
                              EdmiPackedDate    *packedDate,
                              EdmiDate          *date,
                              EdmiStringDate    *stringDate,
                              SdaiInteger       stringFormat,
                              SdaiInvocationId  *edmiInvocationId);


Reads the current time and date from the system clock on the server that runs a remote  EDMdatabase

Arguments


TypeNameComment
SdaiServerContext

serverContextId

Context identification, from edmiDefineServerContext

EdmiPackedDate

packedDate

A variable that will receive the current time and date in an EdmiPackedDate format. Dates from January 1, 1990 to December 31, 2053 may be represented in this format.

EdmiDate

date

A variable that will receive a pointer to an EdmiDate structure containing the current time and date. See sdai.h for the declaration of EdmiDate.  The data structure is a static buffer in the  EDMinterface and may be overwritten by succeeding  EDMinterface calls. Do not release this memory with edmfree  

EdmiStringDate

stringDate

A variable that will receive a pointer to a buffer that contains the current time and date in string format. The string buffer is a static buffer in the  EDMinterface and may be overwritten by succeeding  EDMinterface calls. Do not release this memory with edmfree  

SdaiInteger

stringFormat

Currently not used.

SdaiInvocationId

edmiInvocationId

Currently not used.

Return Value


Error rendering macro 'excerpt-include' : User 'null' does not have permission to view the page 'US:_r_EDMInterface'.

 

Options


  

 

Example


 

 #define S_MAXDIFF 30
 /* Check if the clocks on two servers are
 unsyncronized beyond a threshold value */ 
 EdmiError rstat;
 SdaiServerContext tellusContext, saturnContext;
 EdmiPackedDate tellusPackedDate, saturnPackedDate, dateDiff;
 EdmiDate tellusDate, saturnDate;
 EdmiStringDate tellusStringDate, saturnStringDate;
 SdaiUnsignedInt tellusSeconds, saturnSeconds;
  
 /* Create a Tellus server context */
 rstat = edmiDefineServerContext("TellusContext",
 "superuser", NULL, "xfx56kl9",
 "TCP", "9090", "Tellus",
 NULL, NULL, NULL, NULL, NULL, &tellusContext); 
  
 /* Create a Saturn server context */ 
 rstat = edmiDefineServerContext("SaturnContext",
 "superuser", NULL, "xgg45k22",
 "TCP", "9095", "Saturn",
 NULL, NULL, NULL, NULL, NULL, &saturnContext); 
  
 /* Read the clock on server Tellus */
 rstat = edmiRemoteGetDate(tellusContext, &tellusPackedDate,
 &tellusDate, &tellusStringDate, 0, NULL); 
  
 /* Read the clock on server Saturn */
 rstat = edmiRemoteGetDate(saturnContext, &saturnPackedDate,
 &saturnDate, &saturnStringDate, 0, NULL); 
  
 printf("\nMaster time is (Tellus):");
 printf("\n Year ..............: %d", tellusDate.year);
 printf("\n Month .............: %d", tellusDate.month);
 printf("\n Day .............. : %d", tellusDate.day);
 printf("\n Hour ..............: %d", tellusDate.hour);
 printf("\n Minute ............: %d", tellusDate.minute);
 printf("\n Second ............: %d", tellusDate.second);
 printf("\n WeekDay ...........: %d", tellusDate.weekday);
 printf("\n Day of Year .......: %d", tellusDate.dayOfYear);
 printf("\n daylightSavingTime : %d", tellusDate.daylightSavingTime);
  
 if (tellusDate.dayOfYear != saturnDate.dayOfYear) {
 _sleep(S_MAXDIFF*1000); 
 }
  
 tellusSeconds = 3600 * tellusDate.hour;
 tellusSeconds += 60 * tellusDate.minute;
 tellusSeconds += tellusDate.second;
  
 saturnSeconds = 3600 * saturnDate.hour;
 saturnSeconds += 60 * saturnDate.minute;
 saturnSeconds += saturnDate.second;
  
 dateDiff = saturnSeconds - tellusSeconds;
 if (abs(dateDiff) > S_MAXDIFF) {
 printf("\n\nWARNING!!! Unsyncronized server clocks."); 
 printf("\nSaturn is %d seconds %s Tellus", abs(dateDiff), 
 (dateDiff > 0) ? "ahead of" : "behind"); 
 } else {
 printf("\nServer clocks are syncronized."); 
 printf("\n - Saturn drift is %d seconds", dateDiff);  
 }
 . . . 

 

See also

Filter by label

There are no items with the selected labels at this time.

Â