Changeset 271 in ntrip for trunk


Ignore:
Timestamp:
Nov 4, 2006, 3:29:50 PM (18 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncutils.cpp

    r221 r271  
    2222#include <QRegExp>
    2323#include <QStringList>
     24#include <QDateTime>
    2425
    2526#include "bncutils.h"
     
    5657}
    5758
    58 double MJD(int year, int month, double day) {
    59   if( month <= 2 ) {
    60     year = year - 1;
    61     month = month + 12;
    62   } 
    63   int ii   = year/100;
    64   int kk   = 2 - ii + ii/4;
    65   double mjd = (365.25*year - fmod( 365.25*year, 1.0 )) - 679006.0
    66                 + floor( 30.6001*(month + 1) ) + day + kk;
    67   return mjd;
    68 }
    69 
    70 void MJD_GPSWeeks(double mjd, int& week, double& sec) {
    71   double deltat = mjd - 44244.0 ;
    72   week = (long) floor(deltat/7.0);
    73   sec = (deltat - (week)*7.0)*86400.0;
    74 }
    75 
    7659void currentGPSWeeks(int& week, double& sec) {
    7760
    78   time_t    ltime;
    79   struct tm *gmt;
     61  QDateTime currDateTime = QDateTime::currentDateTime().toUTC();
     62  QDate     currDate = currDateTime.date();
     63  QTime     currTime = currDateTime.time();
    8064
    81   time(&ltime);
    82   gmt = gmtime(&ltime);
     65  week = int( (double(currDate.toJulianDay()) - 2444244.5) / 7 );
    8366
    84   double dayFrac = ((  gmt->tm_sec  / 60.0
    85                      + gmt->tm_min ) / 60.0
    86                      + gmt->tm_hour ) / 24.0;
    87 
    88   double mjd = MJD(1900+gmt->tm_year, gmt->tm_mon+1, gmt->tm_mday+dayFrac);
    89 
    90   MJD_GPSWeeks(mjd, week, sec);
     67  sec = (currDate.dayOfWeek() % 7) * 24.0 * 3600.0 +
     68        currTime.hour()                   * 3600.0 +
     69        currTime.minute()                 *   60.0 +
     70        currTime.second()                          +
     71        currTime.msec()                   / 1000.0;
    9172}
  • trunk/BNC/bncutils.h

    r219 r271  
    1010QDateTime dateAndTimeFromGPSweek(int GPSWeek, double GPSWeeks);
    1111
    12 double MJD(int year, int month, double day);
    13 void MJD_GPSWeeks(double mjd, int& week, double& second);
    1412void currentGPSWeeks(int& week, double& sec);
    1513
Note: See TracChangeset for help on using the changeset viewer.