From: <ai...@us...> - 2009-02-28 18:54:13
|
Revision: 9642 http://plplot.svn.sourceforge.net/plplot/?rev=9642&view=rev Author: airwin Date: 2009-02-28 18:54:06 +0000 (Sat, 28 Feb 2009) Log Message: ----------- Replace all time.h related C library calls by their qsastime equivalents. The result builds without any obvious problems, and example 29 still gives the same results, but this substantial simplification of pldtfac (which affects all time labelling) needs a lot of additional testing. Modified Paths: -------------- trunk/include/plplotP.h trunk/src/pldtik.c Modified: trunk/include/plplotP.h =================================================================== --- trunk/include/plplotP.h 2009-02-28 03:11:55 UTC (rev 9641) +++ trunk/include/plplotP.h 2009-02-28 18:54:06 UTC (rev 9642) @@ -112,7 +112,6 @@ #include <string.h> #include <limits.h> #include <float.h> -#include <time.h> #if defined(PLPLOT_WINTK) #elif defined(WIN32) &! defined (__GNUC__) /* Redefine tmpfile()! (AM)*/ Modified: trunk/src/pldtik.c =================================================================== --- trunk/src/pldtik.c 2009-02-28 03:11:55 UTC (rev 9641) +++ trunk/src/pldtik.c 2009-02-28 18:54:06 UTC (rev 9642) @@ -113,90 +113,72 @@ void pldtfac(PLFLT vmin, PLFLT vmax, PLFLT *factor, PLFLT *start) { PLFLT diff, tdiff; - time_t t, t2; - struct tm tm; + PLINT year, month, day, hour, min; + PLFLT sec; diff = vmax - vmin; if (start != NULL) { - struct tm* tmp; - - t = (time_t) vmin; - if(!(tmp=gmtime(&t))) { - plabort("pldtfac: gmtime() returned an invalid value"); - return; - } - tm = *tmp; - t2 = mktime(&tm); - /* Arg! This is because mktime is in local time and we need to - correct for the offset. C time handling really is broken... */ - tdiff = difftime(t,t2); - + plbtime(&year, &month, &day, &hour, &min, &sec, vmin); } if (diff < 3.0*60.0) { /* Seconds */ *factor = 1.0; if (start != NULL) { - tm.tm_sec = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + plctime(year, month, day, hour, min, sec, start); } } else if (diff < 3.0*60.0*60.0) { /* Minutes */ *factor = 60.0; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + plctime(year, month, day, hour, min, sec, start); } } else if (diff < 3.0*60.0*60.0*24.0) { /* Hours */ *factor = 60.0*60.0; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + hour = 0; + plctime(year, month, day, hour, min, sec, start); } } else if (diff < 3.0*60.0*60.0*24.0*7.0) { /* Days */ *factor = 60.0*60.0*24.0; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + hour = 0; + plctime(year, month, day, hour, min, sec, start); } } else if (diff < 3.0*60.0*60.0*24.0*365) { /* Weeks */ *factor = 60.0*60.0*24.0*7.0; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + hour = 0; + plctime(year, month, day, hour, min, sec, start); } } else { /* Years */ *factor = 60.0*60.0*24.0*365.25; if (start != NULL) { - tm.tm_sec = 0; - tm.tm_min = 0; - tm.tm_hour = 0; - tm.tm_mday = 1; - tm.tm_mon = 0; - t = mktime(&tm); - *start = (PLFLT)t+tdiff; + sec = 0.; + min = 0; + hour = 0; + day = 0; + month = 0; + plctime(year, month, day, hour, min, sec, start); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |