Index: trunk/BNC/bncrinex.cpp
===================================================================
--- trunk/BNC/bncrinex.cpp	(revision 124)
+++ trunk/BNC/bncrinex.cpp	(revision 125)
@@ -25,5 +25,4 @@
 #include "bncrinex.h"
 #include "bncutils.h"
-#include "RTCM3/rtcm3torinex.h"
 
 using namespace std;
@@ -73,5 +72,5 @@
 // File Name according to RINEX Standards
 ////////////////////////////////////////////////////////////////////////////
-void bncRinex::resolveFileName(struct converttimeinfo& cti) {
+void bncRinex::resolveFileName(const QDateTime& datTim) {
 
   QSettings settings;
@@ -83,12 +82,10 @@
   }
 
-  QDate date(cti.year, cti.month, cti.day);
-
   QChar ch = '0';
 
   path += _statID.left(4) +
-          QString("%1%2.%3O").arg(date.dayOfYear(), 3, 10, QChar('0'))
+          QString("%1%2.%3O").arg(datTim.date().dayOfYear(), 3, 10, QChar('0'))
                              .arg(ch)
-                             .arg(date.year() % 100, 2, 10, QChar('0'));
+                             .arg(datTim.date().year() % 100,2,10, QChar('0'));
 
   _fName = path.toAscii();
@@ -97,9 +94,9 @@
 // Write RINEX Header
 ////////////////////////////////////////////////////////////////////////////
-void bncRinex::writeHeader(struct converttimeinfo& cti, double second) {
+void bncRinex::writeHeader(const QDateTime& datTim) {
 
   // Open the Output File
   // --------------------
-  resolveFileName(cti);
+  resolveFileName(datTim);
   _out.open(_fName.data());
   _out.setf(ios::showpoint | ios::fixed);
@@ -116,11 +113,7 @@
       }
       else if (line.indexOf("TIME OF FIRST OBS") != -1) {
-        _out << setw(6) << cti.year
-             << setw(6) << cti.month
-             << setw(6) << cti.day
-             << setw(6) << cti.hour
-             << setw(6) << cti.minute
-             << setw(13) << setprecision(7) << second 
-             << "                 TIME OF FIRST OBS"    << endl;
+        _out << datTim.toString("  yyyy    MM    dd"
+                                "    hh    mm   ss.zzz0000").toAscii().data();
+        _out << "                 TIME OF FIRST OBS"    << endl;
       }
       else {
@@ -158,11 +151,7 @@
     _out << "     1     1                                                WAVELENGTH FACT L1/2" << endl;
     _out << "     4    P1    P2    L1    L2                              # / TYPES OF OBSERV"  << endl;
-    _out << setw(6) << cti.year
-         << setw(6) << cti.month
-         << setw(6) << cti.day
-         << setw(6) << cti.hour
-         << setw(6) << cti.minute
-         << setw(13) << setprecision(7) << second 
-         << "                 "                                      << "TIME OF FIRST OBS"    << endl;
+        _out << datTim.toString("  yyyy    MM    dd"
+                                "    hh    mm   ss.zzz0000").toAscii().data();
+    _out << "                 "                                      << "TIME OF FIRST OBS"    << endl;
     _out << "                                                            END OF HEADER"        << endl;
   }
@@ -191,22 +180,17 @@
   // Time of Epoch
   // -------------
-  struct converttimeinfo cti;
   Observation* firstObs = *_obs.begin();
-  converttime(&cti, firstObs->GPSWeek, firstObs->GPSWeeks);
+
+  QDateTime datTim = dateAndTimeFromGPSweek( firstObs->GPSWeek,
+                                             firstObs->GPSWeeks + 
+                                             fmod(firstObs->sec, 1.0) );
 
   // Write RINEX Header
   // ------------------
   if (!_headerWritten) {
-    writeHeader(cti, cti.second + fmod(firstObs->sec, 1.0));
-  }
-
-  _out << setw(3)  << cti.year%100
-       << setw(3)  << cti.month
-       << setw(3)  << cti.day
-       << setw(3)  << cti.hour
-       << setw(3)  << cti.minute
-       << setw(11) << setprecision(7) 
-       << cti.second + fmod(firstObs->sec, 1.0)
-       << "  " << 0 << setw(3)  << _obs.size();
+    writeHeader(datTim);
+  }
+
+  _out << datTim.toString(" yy MM dd hh mm ss.zzz0000").toAscii().data(); 
 
   QListIterator<Observation*> it(_obs); int iSat = 0;
Index: trunk/BNC/bncrinex.h
===================================================================
--- trunk/BNC/bncrinex.h	(revision 124)
+++ trunk/BNC/bncrinex.h	(revision 125)
@@ -4,4 +4,5 @@
 
 #include <QByteArray>
+#include <QDateTime>
 #include <QList>
 
@@ -18,7 +19,7 @@
 
  private:
-   void resolveFileName(struct converttimeinfo& cti);
+   void resolveFileName(const QDateTime& datTim);
    void readSkeleton();
-   void writeHeader(struct converttimeinfo& cti, double second);
+   void writeHeader(const QDateTime& datTim);
 
    QByteArray          _statID;
Index: trunk/BNC/bncutils.h
===================================================================
--- trunk/BNC/bncutils.h	(revision 124)
+++ trunk/BNC/bncutils.h	(revision 125)
@@ -4,6 +4,9 @@
 
 #include <QString>
+#include <QDateTime>
 
 void expandEnvVar(QString& str);
 
+QDateTime dateAndTimeFromGPSweek(int GPSWeek, double GPSWeeks);
+
 #endif
