head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.40; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.57; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.04; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.22.01; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# sg_time.cxx

    00001 // sg_time.cxx -- data structures and routines for managing time related stuff.
    00002 //
    00003 // Written by Curtis Olson, started August 1997.
    00004 //
    00005 // Copyright (C) 1997  Curtis L. Olson  - curt@@infoplane.com
    00006 //
    00007 // This library is free software; you can redistribute it and/or
    00008 // modify it under the terms of the GNU Library General Public
    00009 // License as published by the Free Software Foundation; either
    00010 // version 2 of the License, or (at your option) any later version.
    00011 //
    00012 // This library is distributed in the hope that it will be useful,
    00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015 // Library General Public License for more details.
    00016 //
    00017 // You should have received a copy of the GNU Library General Public
    00018 // License along with this library; if not, write to the
    00019 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00020 // Boston, MA  02111-1307, USA.
    00021 //
    00022 // $Id: sg_time.cxx,v 1.33 2002/04/03 02:34:20 curt Exp $
    00023
    00024
    00025 #ifdef HAVE_CONFIG_H
    00026 #  include <simgear_config.h>
    00027 #endif
    00028
    00029 #include <simgear/compiler.h>
    00030
    00031 #include <errno.h>              // for errno
    00032
    00033 #ifdef SG_HAVE_STD_INCLUDES
    00034 #  include <cstdio>
    00035 #  include <cstdlib>
    00036 #  include <ctime>
    00037 #else
    00038 #  include <math.h>
    00039 #  include <stdio.h>
    00040 #  include <stdlib.h>
    00041 #endif
    00042
    00043 #ifdef HAVE_SYS_TIME_H
    00044 #  include <sys/time.h>  // for get/setitimer, gettimeofday, struct timeval
    00045 #endif
    00046 #ifdef HAVE_SYS_TIMEB_H
    00047 #  include <sys/timeb.h> // for ftime() and struct timeb
    00048 #endif
    00049 #ifdef HAVE_UNISTD_H
    00050 #  include <unistd.h>    // for gettimeofday()
    00051 #endif
    00052
    00053 #include <math.h>        // for NAN
    00054
    00055 #include <simgear/constants.h>
    00056 #include <simgear/debug/logstream.hxx>
    00057 #include <simgear/misc/sg_path.hxx>
    00058
    00059 #include "sg_time.hxx"
    00060 #include "timezone.h"
    00061 #include "lowleveltime.h"
    00062
    00063
    00064 #define DEGHR(x)        ((x)/15.)
    00065 #define RADHR(x)        DEGHR(x*SGD_RADIANS_TO_DEGREES)
    00066
    00067
    00068 static const double MJD0    = 2415020.0;
    00069 static const double J2000   = 2451545.0 - MJD0;
    00070 static const double SIDRATE = 0.9972695677;
    00071
    00072
    00073 void SGTime::init( double lon, double lat,
    00074                    const string& root, time_t init_time )
    00075 {
    00076     SG_LOG( SG_EVENT, SG_INFO, "Initializing Time" );
    00077
    00078     gst_diff = -9999.0;
    00079
    00080     if ( init_time ) {
    00081         cur_time = init_time;
    00082     } else {
    00083         cur_time = time(NULL);
    00084     }
    00085
    00086     cout << "Current greenwich mean time = " << asctime(gmtime(&cur_time))
    00087          << endl;
    00088     cout << "Current local time          = "
    00089          << asctime(localtime(&cur_time)) << endl;
    00090
    00091     if ( !root.empty()) {
    00092         SGPath zone( root );
    00093         zone.append( "zone.tab" );
    00094         SG_LOG( SG_EVENT, SG_INFO, "Reading timezone info from: "
    00095                 << zone.str() );
    00096         tzContainer = new TimezoneContainer( zone.c_str() );
    00097
    00098         GeoCoord location( SGD_RADIANS_TO_DEGREES * lat, SGD_RADIANS_TO_DEGREES * lon );
    00099         GeoCoord* nearestTz = tzContainer->getNearest(location);
    00100
    00101         SGPath name( root );
    00102         name.append( nearestTz->getDescription() );
    00103         zonename = strdup( name.c_str() );
    00104         SG_LOG( SG_EVENT, SG_INFO, "Using zonename = " << zonename );
    00105     } else {
    00106         SG_LOG( SG_EVENT, SG_INFO, "*** NO TIME ZONE NAME ***" );
    00107         tzContainer = NULL;
    00108         zonename = NULL;
    00109     }
    00110 }
    00111
    00112 SGTime::SGTime( double lon, double lat, const string& root, time_t init_time )
    00113 {
    00114     init( lon, lat, root, init_time );
    00115 }
    00116
    00117
    00118 SGTime::SGTime( const string& root ) {
    00119     init( 0.0, 0.0, root, 0 );
    00120 }
    00121
    00122
    00123 SGTime::SGTime() {
    00124     init( 0.0, 0.0, "", 0 );
    00125 }
    00126
    00127
    00128 SGTime::~SGTime()
    00129 {
    00130     if ( tzContainer != NULL ) {
    00131         TimezoneContainer *tmp = tzContainer;
    00132         tzContainer = NULL;
    00133         delete tmp;
    00134     }
    00135
    00136     if ( zonename != NULL ) {
    00137         char *tmp = zonename;
    00138         zonename = NULL;
    00139         free(tmp);
    00140     }
    00141 }
    00142
    00143
    00144 // given Julian Date and Longitude (decimal degrees West) compute
    00145 // Local Sidereal Time, in decimal hours.
    00146 //
    00147 // Provided courtesy of ecdowney@@noao.edu (Elwood Downey)
    00148 static double sidereal_precise( double mjd, double lng )
    00149 {
    00150     /* printf ("Current Lst on JD %13.5f at %8.4f degrees West: ",
    00151        mjd + MJD0, lng); */
    00152
    00153     // convert to required internal units
    00154     lng *= SGD_DEGREES_TO_RADIANS;
    00155
    00156     // compute LST and print
    00157     double gst = sgTimeCalcGST( mjd );
    00158     double lst = gst - RADHR( lng );
    00159     lst -= 24.0 * floor( lst / 24.0 );
    00160     // printf ("%7.4f\n", lstTmp);
    00161
    00162     return lst;
    00163 }
    00164
    00165
    00166 // return a courser but cheaper estimate of sidereal time
    00167 static double sidereal_course( time_t cur_time, const struct tm *gmt, double lng )
    00168 {
    00169     time_t start_gmt, now;
    00170     double diff, part, days, hours, lstTmp;
    00171     char tbuf[64];
    00172
    00173     now = cur_time;
    00174     start_gmt = sgTimeGetGMT(gmt->tm_year, 2, 21, 12, 0, 0);
    00175
    00176     SG_LOG( SG_EVENT, SG_DEBUG, "  COURSE: GMT = "
    00177             << sgTimeFormatTime(gmt, tbuf) );
    00178     SG_LOG( SG_EVENT, SG_DEBUG, "  March 21 noon (GMT) = " << start_gmt );
    00179
    00180     diff = (now - start_gmt) / (3600.0 * 24.0);
    00181
    00182     SG_LOG( SG_EVENT, SG_DEBUG,
    00183             "  Time since 3/21/" << gmt->tm_year << " GMT = " << diff );
    00184
    00185     part = fmod(diff, 1.0);
    00186     days = diff - part;
    00187     hours = gmt->tm_hour + gmt->tm_min/60.0 + gmt->tm_sec/3600.0;
    00188
    00189     lstTmp = (days - lng)/15.0 + hours - 12;
    00190
    00191     while ( lstTmp < 0.0 ) {
    00192         lstTmp += 24.0;
    00193     }
    00194
    00195     SG_LOG( SG_EVENT, SG_DEBUG,
    00196             "  days = " << days << "  hours = " << hours << "  lon = "
    00197             << lng << "  lst = " << lstTmp );
    00198
    00199     return lstTmp;
    00200 }
    00201
    00202
    00203 // Update the time related variables
    00204 void SGTime::update( double lon, double lat, time_t ct, long int warp ) {
    00205     double gst_precise, gst_course;
    00206
    00207 #if defined(_MSC_VER) || defined(__MINGW32__)
    00208     tm * gmt = &m_gmt;
    00209 #endif
    00210
    00211     SG_LOG( SG_EVENT, SG_DEBUG, "Updating time" );
    00212
    00213     // get current Unix calendar time (in seconds)
    00214     // warp += warp_delta;
    00215     if ( ct ) {
    00216         cur_time = ct + warp;
    00217     } else {
    00218         cur_time = time(NULL) + warp;
    00219     }
    00220     SG_LOG( SG_EVENT, SG_DEBUG,
    00221             "  Current Unix calendar time = " << cur_time
    00222             << "  warp = " << warp );
    00223
    00224     // get GMT break down for current time
    00225 #if defined(_MSC_VER) || defined(__MINGW32__)
    00226     memcpy( gmt, gmtime(&cur_time), sizeof(tm) );
    00227 #else
    00228     gmt = gmtime(&cur_time);
    00229 #endif
    00230     SG_LOG( SG_EVENT, SG_DEBUG,
    00231             "  Current GMT = " << gmt->tm_mon+1 << "/"
    00232             << gmt->tm_mday << "/" << (1900 + gmt->tm_year) << " "
    00233             << gmt->tm_hour << ":" << gmt->tm_min << ":"
    00234             << gmt->tm_sec );
    00235
    00236     // calculate modified Julian date starting with current
    00237     mjd = sgTimeCurrentMJD( ct, warp );
    00238
    00239     // add in partial day
    00240     mjd += (gmt->tm_hour / 24.0) + (gmt->tm_min / (24.0 * 60.0)) +
    00241         (gmt->tm_sec / (24.0 * 60.0 * 60.0));
    00242
    00243     // convert "back" to Julian date + partial day (as a fraction of one)
    00244     jd = mjd + MJD0;
    00245     SG_LOG( SG_EVENT, SG_DEBUG, "  Current Julian Date = " << jd );
    00246
    00247     // printf("  Current Longitude = %.3f\n", FG_Longitude * SGD_RADIANS_TO_DEGREES);
    00248
    00249     // Calculate local side real time
    00250     if ( gst_diff < -100.0 ) {
    00251         // first time through do the expensive calculation & cheap
    00252         // calculation to get the difference.
    00253         SG_LOG( SG_EVENT, SG_INFO, "  First time, doing precise gst" );
    00254         gst_precise = gst = sidereal_precise( mjd, 0.00 );
    00255         gst_course = sidereal_course( cur_time, gmt, 0.00 );
    00256
    00257         gst_diff = gst_precise - gst_course;
    00258
    00259         lst = sidereal_course( cur_time, gmt, -(lon * SGD_RADIANS_TO_DEGREES) ) + gst_diff;
    00260     } else {
    00261         // course + difference should drift off very slowly
    00262         gst = sidereal_course( cur_time, gmt, 0.00 ) + gst_diff;
    00263         lst = sidereal_course( cur_time, gmt, -(lon * SGD_RADIANS_TO_DEGREES) ) + gst_diff;
    00264     }
    00265
    00266     SG_LOG( SG_EVENT, SG_DEBUG,
    00267             "  Current lon=0.00 Sidereal Time = " << gst );
    00268     SG_LOG( SG_EVENT, SG_DEBUG,
    00269             "  Current LOCAL Sidereal Time = " << lst << " ("
    00270             << sidereal_precise( mjd, -(lon * SGD_RADIANS_TO_DEGREES) )
    00271             << ") (diff = " << gst_diff << ")" );
    00272 }
    00273
    00274
    00275 // Given lon/lat, update timezone information and local_offset
    00276 void SGTime::updateLocal( double lon, double lat, const string& root ) {
    00277     // sanity checking
    00278     if ( lon < -SGD_PI || lon > SGD_PI ) {
    00279         // not within -180 ... 180
    00280         lon = 0.0;
    00281     }
    00282     if ( lat < -SGD_PI * 0.5 || lat > SGD_PI * 0.5 ) {
    00283         // not within -90 ... 90
    00284         lat = 0.0;
    00285     }
    00286     if ( lon != lon ) {
    00287         // only true if lon == nan
    00288         SG_LOG( SG_EVENT, SG_ALERT, "  Detected lon == nan, resetting to 0.0" );
    00289         lon = 0.0;
    00290     }
    00291     if ( lat != lat ) {
    00292         // only true if lat == nan
    00293         SG_LOG( SG_EVENT, SG_ALERT, "  Detected lat == nan, resetting to 0.0" );
    00294         lat = 0.0;
    00295     }
    00296     time_t currGMT;
    00297     time_t aircraftLocalTime;
    00298     GeoCoord location( SGD_RADIANS_TO_DEGREES * lat, SGD_RADIANS_TO_DEGREES * lon );
    00299     GeoCoord* nearestTz = tzContainer->getNearest(location);
    00300     SGPath zone( root );
    00301     zone.append ( nearestTz->getDescription() );
    00302     if ( zonename ) {
    00303         char *ptr = zonename;
    00304         zonename = NULL;
    00305         free(ptr);
    00306     }
    00307     zonename = strdup( zone.c_str() );
    00308
    00309     //Avoid troubles when zone.tab hasn't got the right line endings
    00310     if (zonename[strlen(zonename)-1] == '\r')
    00311     {
    00312       zonename[strlen(zonename)-1]=0;
    00313       zone.set( zonename );
    00314     }
    00315
    00316     currGMT = sgTimeGetGMT( gmtime(&cur_time) );
    00317     aircraftLocalTime = sgTimeGetGMT( (fgLocaltime(&cur_time, zone.c_str())) );
    00318     local_offset = aircraftLocalTime - currGMT;
    00319     // cout << "Using " << local_offset << " as local time offset Timezone is "
    00320     //      << zonename << endl;
    00321 }
    00322
    00323
    00324 // given a date in months, mn, days, dy, years, yr, return the
    00325 // modified Julian date (number of days elapsed since 1900 jan 0.5),
    00326 // mjd.  Adapted from Xephem.
    00327 double sgTimeCalcMJD(int mn, double dy, int yr) {
    00328     double mjd;
    00329
    00330     // internal book keeping data
    00331     static double last_mjd, last_dy;
    00332     static int last_mn, last_yr;
    00333
    00334     int b, d, m, y;
    00335     long c;
    00336
    00337     if (mn == last_mn && yr == last_yr && dy == last_dy) {
    00338         mjd = last_mjd;
    00339     }
    00340
    00341     m = mn;
    00342     y = (yr < 0) ? yr + 1 : yr;
    00343     if (mn < 3) {
    00344         m += 12;
    00345         y -= 1;
    00346     }
    00347
    00348     if (yr < 1582 || (yr == 1582 && (mn < 10 || (mn == 10 && dy < 15)))) {
    00349         b = 0;
    00350     } else {
    00351         int a;
    00352         a = y/100;
    00353         b = 2 - a + a/4;
    00354     }
    00355
    00356     if (y < 0) {
    00357         c = (long)((365.25*y) - 0.75) - 694025L;
    00358     } else {
    00359         c = (long)(365.25*y) - 694025L;
    00360     }
    00361
    00362     d = (int)(30.6001*(m+1));
    00363
    00364     mjd = b + c + d + dy - 0.5;
    00365
    00366     last_mn = mn;
    00367     last_dy = dy;
    00368     last_yr = yr;
    00369     last_mjd = mjd;
    00370
    00371     return mjd;
    00372 }
    00373
    00374
    00375 // return the current modified Julian date (number of days elapsed
    00376 // since 1900 jan 0.5), mjd.
    00377 double sgTimeCurrentMJD( time_t ct, long int warp ) {
    00378
    00379 #if defined(_MSC_VER) || defined(__MINGW32__)
    00380     struct tm m_gmt;    // copy of system gmtime(&time_t) structure
    00381     struct tm *gmt = &m_gmt;
    00382 #else
    00383     struct tm *gmt;
    00384 #endif
    00385
    00386     // get current Unix calendar time (in seconds)
    00387     // warp += warp_delta;
    00388     time_t cur_time;
    00389     if ( ct ) {
    00390         cur_time = ct + warp;
    00391     } else {
    00392         cur_time = time(NULL) + warp;
    00393     }
    00394     SG_LOG( SG_EVENT, SG_DEBUG,
    00395             "  Current Unix calendar time = " << cur_time
    00396             << "  warp = " << warp );
    00397
    00398     // get GMT break down for current time
    00399 #if defined(_MSC_VER) || defined(__MINGW32__)
    00400     memcpy( gmt, gmtime(&cur_time), sizeof(tm) );
    00401 #else
    00402     gmt = gmtime(&cur_time);
    00403 #endif
    00404     SG_LOG( SG_EVENT, SG_DEBUG,
    00405             "  Current GMT = " << gmt->tm_mon+1 << "/"
    00406             << gmt->tm_mday << "/" << (1900 + gmt->tm_year) << " "
    00407             << gmt->tm_hour << ":" << gmt->tm_min << ":"
    00408             << gmt->tm_sec );
    00409
    00410     // calculate modified Julian date
    00411     // t->mjd = cal_mjd ((int)(t->gmt->tm_mon+1), (double)t->gmt->tm_mday,
    00412     //     (int)(t->gmt->tm_year + 1900));
    00413     double mjd = sgTimeCalcMJD( (int)(gmt->tm_mon+1), (double)gmt->tm_mday,
    00414                                 (int)(gmt->tm_year + 1900) );
    00415
    00416     return mjd;
    00417 }
    00418
    00419
    00420 // given an mjd, calculate greenwich mean sidereal time, gst
    00421 double sgTimeCalcGST( double mjd ) {
    00422     double gst;
    00423
    00424     double day = floor(mjd-0.5)+0.5;
    00425     double hr = (mjd-day)*24.0;
    00426     double T, x;
    00427
    00428     T = ((int)(mjd - 0.5) + 0.5 - J2000)/36525.0;
    00429     x = 24110.54841 + (8640184.812866 + (0.093104 - 6.2e-6 * T) * T) * T;
    00430     x /= 3600.0;
    00431     gst = (1.0/SIDRATE)*hr + x;
    00432
    00433     SG_LOG( SG_EVENT, SG_DEBUG, "  gst => " << gst );
    00434
    00435     return gst;
    00436 }
    00437
    00438
    00439 #if defined( HAVE_TIMEGM )
    00440     // ignore this function
    00441 #elif defined( MK_TIME_IS_GMT )
    00442     // ignore this function
    00443 #else // ! defined ( MK_TIME_IS_GMT )
    00444
    00445     // Fix up timezone if using ftime()
    00446     static long int fix_up_timezone( long int timezone_orig ) {
    00447 #   if !defined( HAVE_GETTIMEOFDAY ) && defined( HAVE_FTIME )
    00448         // ftime() needs a little extra help finding the current timezone
    00449         struct timeb current;
    00450         ftime(&current);
    00451         return( current.timezone * 60 );
    00452 #   else
    00453         return( timezone_orig );
    00454 #   endif
    00455     }
    00456 #endif
    00457
    00458
    00459 /******************************************************************
    00460  * The following are some functions that were included as SGTime
    00461  * members, although they currently don't make use of any of the
    00462  * class's variables. Maybe this'll change in the future
    00463  *****************************************************************/
    00464
    00465 // Return time_t for Sat Mar 21 12:00:00 GMT
    00466 //
    00467 // On many systems it is ambiguous if mktime() assumes the input is in
    00468 // GMT, or local timezone.  To address this, a new function called
    00469 // timegm() is appearing.  It works exactly like mktime() but
    00470 // explicitely interprets the input as GMT.
    00471 //
    00472 // timegm() is available and documented under FreeBSD.  It is
    00473 // available, but completely undocumented on my current Debian 2.1
    00474 // distribution.
    00475 //
    00476 // In the absence of timegm() we have to guess what mktime() might do.
    00477 //
    00478 // Many older BSD style systems have a mktime() that assumes the input
    00479 // time in GMT.  But FreeBSD explicitly states that mktime() assumes
    00480 // local time zone
    00481 //
    00482 // The mktime() on many SYSV style systems (such as Linux) usually
    00483 // returns its result assuming you have specified the input time in
    00484 // your local timezone.  Therefore, in the absence if timegm() you
    00485 // have to go to extra trouble to convert back to GMT.
    00486 //
    00487 // If you are having problems with incorrectly positioned astronomical
    00488 // bodies, this is a really good place to start looking.
    00489
    00490 time_t sgTimeGetGMT(int year, int month, int day, int hour, int min, int sec)
    00491 {
    00492     struct tm mt;
    00493
    00494     mt.tm_mon = month;
    00495     mt.tm_mday = day;
    00496     mt.tm_year = year;
    00497     mt.tm_hour = hour;
    00498     mt.tm_min = min;
    00499     mt.tm_sec = sec;
    00500     mt.tm_isdst = -1; // let the system determine the proper time zone
    00501
    00502     // For now we assume that if daylight is not defined in
    00503     // /usr/include/time.h that we have a machine with a mktime() that
    00504     // assumes input is in GMT ... this only matters if we are
    00505     // building on a system that does not have timegm()
    00506 #if !defined(HAVE_DAYLIGHT)
    00507 #  define MK_TIME_IS_GMT 1
    00508 #endif
    00509
    00510 #if defined( HAVE_TIMEGM )
    00511     return ( timegm(&mt) );
    00512 #elif defined( MK_TIME_IS_GMT )
    00513     time_t ret = mktime(&mt);
    00514
    00515 #ifdef __CYGWIN__
    00516         ret -= _timezone;
    00517 #endif
    00518
    00519     // This is necessary as some mktime() calls may
    00520     // try to access the system timezone files
    00521     // if this open fails errno is set to 2
    00522     // CYGWIN for one does this
    00523     // if ( errno ) {
    00524     //     perror( "sgTimeGetGMT()" );
    00525     //     errno = 0;
    00526     // }
    00527
    00528     // reset errno in any event.
    00529     errno = 0;
    00530
    00531     return ret;
    00532 #else // ! defined ( MK_TIME_IS_GMT )
    00533
    00534     // timezone seems to work as a proper offset for Linux & Solaris
    00535 #   if defined( __linux__ ) || defined( __sun__ ) ||defined(__CYGWIN__)
    00536 #       define TIMEZONE_OFFSET_WORKS 1
    00537 #   endif
    00538
    00539 #if defined(__CYGWIN__)
    00540 #define TIMEZONE _timezone
    00541 #else
    00542 #define TIMEZONE timezone
    00543 #endif
    00544
    00545     time_t start = mktime(&mt);
    00546
    00547     SG_LOG( SG_EVENT, SG_DEBUG, "start1 = " << start );
    00548     // the ctime() call can screw up time progression on some versions
    00549     // of Linux
    00550     // fgPrintf( SG_EVENT, SG_DEBUG, "start2 = %s", ctime(&start));
    00551     SG_LOG( SG_EVENT, SG_DEBUG, "(tm_isdst = " << mt.tm_isdst << ")" );
    00552
    00553     TIMEZONE = fix_up_timezone( TIMEZONE );
    00554
    00555 #  if defined( TIMEZONE_OFFSET_WORKS )
    00556     SG_LOG( SG_EVENT, SG_DEBUG,
    00557             "start = " << start << ", timezone = " << TIMEZONE );
    00558     return( start - TIMEZONE );
    00559 #  else // ! defined( TIMEZONE_OFFSET_WORKS )
    00560
    00561     daylight = mt.tm_isdst;
    00562     if ( daylight > 0 ) {
    00563         daylight = 1;
    00564     } else if ( daylight < 0 ) {
    00565         SG_LOG( SG_EVENT, FG_WARN,
    00566                 "OOOPS, problem in sg_time.cxx, no daylight savings info." );
    00567     }
    00568
    00569     long int offset = -(TIMEZONE / 3600 - daylight);
    00570
    00571     SG_LOG( SG_EVENT, SG_DEBUG, "  Raw time zone offset = " << TIMEZONE );
    00572     SG_LOG( SG_EVENT, SG_DEBUG, "  Daylight Savings = " << daylight );
    00573     SG_LOG( SG_EVENT, SG_DEBUG, "  Local hours from GMT = " << offset );
    00574
    00575     long int start_gmt = start - TIMEZONE + (daylight * 3600);
    00576
    00577     SG_LOG( SG_EVENT, SG_DEBUG, "  March 21 noon (CST) = " << start );
    00578
    00579     return ( start_gmt );
    00580 #  endif // ! defined( TIMEZONE_OFFSET_WORKS )
    00581 #endif // ! defined ( MK_TIME_IS_GMT )
    00582 }
    00583
    00584
    00585 // format time
    00586 char* sgTimeFormatTime( const struct tm* p, char* buf )
    00587 {
    00588     sprintf( buf, "%d/%d/%2d %d:%02d:%02d",
    00589              p->tm_mon, p->tm_mday, p->tm_year,
    00590              p->tm_hour, p->tm_min, p->tm_sec);
    00591     return buf;
    00592 }

@ 1.3 log @Oops, try again. @ text @d601 1 a601 1