- Timestamp:
- Nov 4, 2006, 3:29:50 PM (18 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncutils.cpp
r221 r271 22 22 #include <QRegExp> 23 23 #include <QStringList> 24 #include <QDateTime> 24 25 25 26 #include "bncutils.h" … … 56 57 } 57 58 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.066 + 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 76 59 void currentGPSWeeks(int& week, double& sec) { 77 60 78 time_t ltime; 79 struct tm *gmt; 61 QDateTime currDateTime = QDateTime::currentDateTime().toUTC(); 62 QDate currDate = currDateTime.date(); 63 QTime currTime = currDateTime.time(); 80 64 81 time(<ime); 82 gmt = gmtime(<ime); 65 week = int( (double(currDate.toJulianDay()) - 2444244.5) / 7 ); 83 66 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; 91 72 } -
trunk/BNC/bncutils.h
r219 r271 10 10 QDateTime dateAndTimeFromGPSweek(int GPSWeek, double GPSWeeks); 11 11 12 double MJD(int year, int month, double day);13 void MJD_GPSWeeks(double mjd, int& week, double& second);14 12 void currentGPSWeeks(int& week, double& sec); 15 13
Note:
See TracChangeset
for help on using the changeset viewer.