#include <ctype.h>
#include <math.h>
-#ifndef isnan
#ifdef WIN32
#include <float.h>
#endif
#endif
-#ifdef __APPLE__
-#define isnan __isnanf
+// For some reason isnan() isn't working on macosx any more.
+// This is a quick fix.
+#if defined(__APPLE__) && !defined(SYNFIG_ISNAN_FIX)
+#ifdef isnan
+#undef isnan
#endif
-
+inline bool isnan(double x) { return x != x; }
+inline bool isnan(float x) { return x != x; }
+#define SYNFIG_ISNAN_FIX 1
#endif
+
#endif
/* === U S I N G =========================================================== */
unsigned int pos=0;
int read;
float amount;
-
+
// Now try to read it in the letter-abreviated format
while(pos<str.size() && sscanf(String(str,pos).c_str(),"%f%n",&amount,&read))
{
value_=frame/fps+(hour*3600+minute*60+second);
return;
}
-
+
if(sscanf(str.c_str(),"%d:%d:%d",&hour,&minute,&second)==3)
{
value_=hour*3600+minute*60+second;
Time::get_string(float fps, Time::Format format)const
{
Time time(*this);
-
+
if(time<=begin())
return "SOT"; // Start Of Time
if(time>=end())
return "EOT"; // End Of Time
-
+
if(fps<0)fps=0;
-
+
if(ceil(time.value_)-time.value_<epsilon_())
time.value_=ceil(time.value_);
-
+
int hour,minute;
-
+
hour=time/3600;time-=hour*3600;
minute=time/60;time-=minute*60;
-
+
if(format<=FORMAT_VIDEO)
{
int second;
else
return strprintf("%02d:%02d:%02d",hour,minute,second);
}
-
+
String ret;
if(format<=FORMAT_FULL || hour)
ret+=strprintf(format<=FORMAT_NOSPACES?"%dh":"%dh ",hour);
-
+
if(format<=FORMAT_FULL || hour || minute)
ret+=strprintf(format<=FORMAT_NOSPACES?"%dm":"%dm ",minute);
-
+
if(fps)
{
int second;
frame=time*fps;
if(format<=FORMAT_FULL || second)
ret+=strprintf(format<=FORMAT_NOSPACES?"%ds":"%ds ",(int)second);
-
+
if(abs(frame-floor(frame)>=epsilon_()))
ret+=strprintf("%0.3ff",frame);
else
else
ret+=strprintf("%0.0fs",second);
}
-
+
return ret;
}