source: ntrip/trunk/BNC/bncutils.cpp@ 207

Last change on this file since 207 was 124, checked in by mervart, 18 years ago

* empty log message *

File size: 1.2 KB
Line 
1
2/* -------------------------------------------------------------------------
3 * BKG NTRIP Client
4 * -------------------------------------------------------------------------
5 *
6 * Class: bncutils
7 *
8 * Purpose: Auxiliary Functions
9 *
10 * Author: L. Mervart
11 *
12 * Created: 30-Aug-2006
13 *
14 * Changes:
15 *
16 * -----------------------------------------------------------------------*/
17
18#include <iostream>
19
20#include <QRegExp>
21#include <QStringList>
22
23#include "bncutils.h"
24
25using namespace std;
26
27void expandEnvVar(QString& str) {
28
29 QRegExp rx("(\\$\\{.+\\})");
30
31 if (rx.indexIn(str) != -1) {
32 QStringListIterator it(rx.capturedTexts());
33 if (it.hasNext()) {
34 QString rxStr = it.next();
35 QString envVar = rxStr.mid(2,rxStr.length()-3);
36 str.replace(rxStr, qgetenv(envVar.toAscii()));
37 }
38 }
39
40}
41
42QDateTime dateAndTimeFromGPSweek(int GPSWeek, double GPSWeeks) {
43
44 static const QDate zeroEpoch(1980, 1, 6);
45
46 QDate date(zeroEpoch);
47 QTime time(0,0,0,0);
48
49 int weekDays = int(GPSWeeks) / 86400;
50 date = date.addDays( GPSWeek * 7 + weekDays );
51 time = time.addMSecs( int( (GPSWeeks - 86400 * weekDays) * 1e3 ) );
52
53 return QDateTime(date,time);
54}
Note: See TracBrowser for help on using the repository browser.