Changeset 8372 in ntrip for trunk/BNC/src/bnctime.cpp
- Timestamp:
- Jun 13, 2018, 2:37:07 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bnctime.cpp
r7138 r8372 17 17 this->set(gpsw, gpssec); 18 18 } 19 19 20 20 // Constructor (from ISO String yyyy-mm-ddThh:mm:ss) 21 21 ////////////////////////////////////////////////////////////////////////////// … … 24 24 QDateTime dt = QDateTime::fromString(isoString.c_str(), Qt::ISODate); 25 25 this->set(dt.date().year(), dt.date().month(), dt.date().day(), 26 dt.time().hour(), dt.time().minute(), 26 dt.time().hour(), dt.time().minute(), 27 27 dt.time().second() + dt.time().msec()/1000.0); 28 28 } … … 32 32 } 33 33 34 // 34 // 35 35 ////////////////////////////////////////////////////////////////////////////// 36 36 bncTime& bncTime::set(int gpsw, double gpssec) { 37 37 int deltad; 38 38 int dow = 0; 39 while ( gpssec >= 86400 ) {40 gpssec-=86400 ;39 while ( gpssec >= 86400.0 ) { 40 gpssec-=86400.0; 41 41 dow++; 42 42 } 43 while ( gpssec < 0 ) {44 gpssec+=86400 ;43 while ( gpssec < 0.0 ) { 44 gpssec+=86400.0; 45 45 dow--; 46 46 } … … 59 59 gpssec += 14.0; 60 60 gpsw += 1356.0; 61 while ( gpssec >= 86400 ) {62 gpssec-=86400 ;61 while ( gpssec >= 86400.0 ) { 62 gpssec-=86400.0; 63 63 dow++; 64 64 } 65 while ( gpssec < 0 ) {66 gpssec+=86400 ;65 while ( gpssec < 0.0 ) { 66 gpssec+=86400.0; 67 67 dow--; 68 68 } … … 73 73 } 74 74 75 // 75 // 76 76 ////////////////////////////////////////////////////////////////////////////// 77 77 bncTime &bncTime::set(int msec) { … … 85 85 } 86 86 87 // 87 // 88 88 ////////////////////////////////////////////////////////////////////////////// 89 89 bncTime &bncTime::setTOD(int msec) { … … 108 108 } 109 109 110 // 110 // 111 111 ////////////////////////////////////////////////////////////////////////////// 112 112 bncTime &bncTime::setTk(int msec) { … … 122 122 } 123 123 124 // 124 // 125 125 ////////////////////////////////////////////////////////////////////////////// 126 126 bncTime &bncTime::setBDS(int msec) { … … 137 137 } 138 138 139 // 139 // 140 140 ////////////////////////////////////////////////////////////////////////////// 141 141 bncTime& bncTime::setmjd(double daysec, int mjd) { 142 142 _sec = daysec; 143 143 _mjd = mjd; 144 while ( _sec >= 86400 ) {145 _sec-=86400 ;144 while ( _sec >= 86400.0 ) { 145 _sec-=86400.0; 146 146 _mjd++; 147 147 } 148 while ( _sec < 0 ) {149 _sec+=86400 ;148 while ( _sec < 0.0 ) { 149 _sec+=86400.0; 150 150 _mjd--; 151 151 } … … 153 153 } 154 154 155 // 155 // 156 156 ////////////////////////////////////////////////////////////////////////////// 157 157 bncTime& bncTime::setmjd(double mjddec) { … … 161 161 } 162 162 163 // 163 // 164 164 ////////////////////////////////////////////////////////////////////////////// 165 165 unsigned int bncTime::mjd() const { 166 166 return _mjd; 167 167 } 168 168 169 169 // 170 170 ////////////////////////////////////////////////////////////////////////////// … … 182 182 } 183 183 184 // 184 // 185 185 ////////////////////////////////////////////////////////////////////////////// 186 186 double bncTime::gpssec() const { … … 202 202 } 203 203 204 // 204 // 205 205 ////////////////////////////////////////////////////////////////////////////// 206 206 double bncTime::bdssec() const { … … 215 215 } 216 216 217 // 217 // 218 218 ////////////////////////////////////////////////////////////////////////////// 219 219 bool bncTime::operator!=(const bncTime &time1) const { … … 226 226 } 227 227 228 // 228 // 229 229 ////////////////////////////////////////////////////////////////////////////// 230 230 bool bncTime::operator==(const bncTime &time1) const { … … 237 237 } 238 238 239 // 239 // 240 240 ////////////////////////////////////////////////////////////////////////////// 241 241 bool bncTime::operator>(const bncTime &time1) const { … … 248 248 } 249 249 250 // 250 // 251 251 ////////////////////////////////////////////////////////////////////////////// 252 252 bool bncTime::operator>=(const bncTime &time1) const { … … 259 259 } 260 260 261 // 261 // 262 262 ////////////////////////////////////////////////////////////////////////////// 263 263 bool bncTime::operator<(const bncTime &time1) const { … … 270 270 } 271 271 272 // 272 // 273 273 ////////////////////////////////////////////////////////////////////////////// 274 274 bool bncTime::operator<=(const bncTime &time1) const { … … 281 281 } 282 282 283 // 283 // 284 284 ////////////////////////////////////////////////////////////////////////////// 285 285 bncTime bncTime::operator+(double sec) const { … … 290 290 } 291 291 292 // 292 // 293 293 ////////////////////////////////////////////////////////////////////////////// 294 294 bncTime bncTime::operator-(double sec) const { … … 296 296 } 297 297 298 // 298 // 299 299 ////////////////////////////////////////////////////////////////////////////// 300 300 double bncTime::operator-(const bncTime &time1) const { … … 323 323 } 324 324 325 // 325 // 326 326 ////////////////////////////////////////////////////////////////////////////// 327 327 void bncTime::civil_date (unsigned int& year, unsigned int& month, … … 335 335 } 336 336 337 // 338 ////////////////////////////////////////////////////////////////////////////// 339 void bncTime::civil_time(unsigned int &hour, unsigned int &min, 337 // 338 ////////////////////////////////////////////////////////////////////////////// 339 void bncTime::civil_time(unsigned int &hour, unsigned int &min, 340 340 double &sec) const { 341 341 hour = static_cast<unsigned int>(_sec/3600.0); … … 352 352 } 353 353 354 // 354 // 355 355 ////////////////////////////////////////////////////////////////////////////// 356 356 string bncTime::timestr(unsigned numdec, char sep) const { … … 386 386 } 387 387 388 // 388 // 389 389 ////////////////////////////////////////////////////////////////////////////// 390 390 string bncTime::datestr(char sep) const { … … 402 402 } 403 403 404 // 404 // 405 405 ////////////////////////////////////////////////////////////////////////////// 406 406 bncTime::operator std::string() const { … … 408 408 } 409 409 410 // 411 ////////////////////////////////////////////////////////////////////////////// 412 bncTime& bncTime::set(int year, int month, int day, 410 // 411 ////////////////////////////////////////////////////////////////////////////// 412 bncTime& bncTime::set(int year, int month, int day, 413 413 int hour, int min, double sec) { 414 414 return set(year, month, day, hour*3600 + min*60 + sec); 415 415 } 416 416 417 // 418 ////////////////////////////////////////////////////////////////////////////// 419 bncTime& bncTime::setBDS(int year, int month, int day, 417 // 418 ////////////////////////////////////////////////////////////////////////////// 419 bncTime& bncTime::setBDS(int year, int month, int day, 420 420 int hour, int min, double sec) { 421 421 return set(year, month, day, hour*3600 + min*60 + sec+14.0); 422 422 } 423 423 424 // 424 // 425 425 ////////////////////////////////////////////////////////////////////////////// 426 426 bncTime& bncTime::set(int year, int month, int day, double daysec) { 427 427 _sec = daysec; 428 428 429 429 _mjd = (unsigned int)djul(year, month, day); 430 430 431 431 while ( _sec >= 86400 ) { 432 432 _sec-=86400;
Note:
See TracChangeset
for help on using the changeset viewer.