+// return the current modified Julian date (number of days elapsed
+// since 1900 jan 0.5), mjd.
+double sgTimeCurrentMJD( time_t ct, long int warp ) {
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ struct tm m_gmt; // copy of system gmtime(&time_t) structure
+ struct tm *gmt = &m_gmt;
+#else
+ struct tm *gmt;
+#endif
+
+ // get current Unix calendar time (in seconds)
+ // warp += warp_delta;
+ time_t cur_time;
+ if ( ct ) {
+ cur_time = ct + warp;
+ } else {
+ cur_time = time(NULL) + warp;
+ }
+ SG_LOG( SG_EVENT, SG_DEBUG,
+ " Current Unix calendar time = " << cur_time
+ << " warp = " << warp );
+
+ // get GMT break down for current time
+#if defined(_MSC_VER) || defined(__MINGW32__)
+ memcpy( gmt, gmtime(&cur_time), sizeof(tm) );
+#else
+ gmt = gmtime(&cur_time);
+#endif
+ SG_LOG( SG_EVENT, SG_DEBUG,
+ " Current GMT = " << gmt->tm_mon+1 << "/"
+ << gmt->tm_mday << "/" << (1900 + gmt->tm_year) << " "
+ << gmt->tm_hour << ":" << gmt->tm_min << ":"
+ << gmt->tm_sec );
+
+ // calculate modified Julian date
+ // t->mjd = cal_mjd ((int)(t->gmt->tm_mon+1), (double)t->gmt->tm_mday,
+ // (int)(t->gmt->tm_year + 1900));
+ double mjd = sgTimeCalcMJD( (int)(gmt->tm_mon+1), (double)gmt->tm_mday,
+ (int)(gmt->tm_year + 1900) );
+
+ return mjd;
+}
+
+