Skip to content
Snippets Groups Projects
Commit da8b7dcb authored by rswindell's avatar rswindell
Browse files

Move checktime() implementation to datewrap.* and always call checktime()

in xptime.
parent e4c7c15d
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,19 @@
#include "genwrap.h"
#include "datewrap.h"
/* Return difference (in seconds) in time() result from standard */
time_t checktime(void)
{
time_t t=0x2D24BD00L; /* Correct time_t value on Jan-1-1994 */
struct tm gmt;
struct tm tm;
memset(&tm,0,sizeof(tm));
tm.tm_year=94;
tm.tm_mday=1;
return mktime(&tm) - mktime(gmtime_r(&t,&gmt));
}
/* Compensates for struct tm "weirdness" */
time_t sane_mktime(struct tm* tm)
{
......
......@@ -44,6 +44,9 @@
extern "C" {
#endif
/* Return difference (in seconds) in time() result from standard (0 on success) */
time_t checktime(void);
/* Implementation of mktime() that handles common tm element conversions for you */
time_t sane_mktime(struct tm* tm);
......
......@@ -13,16 +13,6 @@
#include "datewrap.h"
#include "xpdatetime.h"
time_t checktime()
{
struct tm tm;
memset(&tm,0,sizeof(tm));
tm.tm_year=94;
tm.tm_mday=1;
return(mktime(&tm)^0x2D24BD00L);
}
int main(int argc, char **argv)
{
char str[256];
......@@ -39,13 +29,6 @@ int main(int argc, char **argv)
printf("Rev %s Built " __DATE__ " " __TIME__ " with %s\n\n", revision, str);
#if 0
if((t=checktime())!=0L) {
printf("Time problem (%08lX)\n",t);
exit(1); }
#endif
if(argc<2)
printf("usage: xptime [-z] <date_str || time_t>\n\n");
......@@ -56,6 +39,9 @@ int main(int argc, char **argv)
}
tzset();
if((t=checktime())!=0L)
printf("!time() result diverges from standard by: %ld seconds\n\n",t);
printf("Current timezone: %d\n", xpTimeZone_local());
printf("\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment