Index: trunk/BNC/RTCM3/rtcm3torinex.c
===================================================================
--- trunk/BNC/RTCM3/rtcm3torinex.c	(revision 2255)
+++ trunk/BNC/RTCM3/rtcm3torinex.c	(revision 2256)
@@ -1,5 +1,5 @@
 /*
   Converter for RTCM3 data to RINEX.
-  $Id: rtcm3torinex.c,v 1.28 2010/01/12 12:13:23 mervart Exp $
+  $Id: rtcm3torinex.c,v 1.29 2010/01/16 10:18:44 mervart Exp $
   Copyright (C) 2005-2008 by Dirk Stöcker <stoecker@alberding.eu>
 
@@ -55,5 +55,5 @@
 
 /* CVS revision and version */
-static char revisionstr[] = "$Revision: 1.28 $";
+static char revisionstr[] = "$Revision: 1.29 $";
 
 #ifndef COMPILEDATE
@@ -251,4 +251,5 @@
 }
 
+// Convert Moscow time into UTC (fixnumleap == 1) or GPS (fixnumleap == 0)
 void updatetime(int *week, int *secOfWeek, int mSecOfWeek, int fixnumleap)
 {
@@ -1683,5 +1684,5 @@
 
 #ifndef NO_RTCM3_MAIN
-static char datestr[]     = "$Date: 2010/01/12 12:13:23 $";
+static char datestr[]     = "$Date: 2010/01/16 10:18:44 $";
 
 /* The string, which is send as agent in HTTP request */
Index: trunk/BNS/RTCM/rtcm3torinex.c
===================================================================
--- trunk/BNS/RTCM/rtcm3torinex.c	(revision 2255)
+++ trunk/BNS/RTCM/rtcm3torinex.c	(revision 2256)
@@ -1,5 +1,5 @@
 /*
   Converter for RTCM3 data to RINEX.
-  $Id: rtcm3torinex.c,v 1.28 2010/01/12 12:13:23 mervart Exp $
+  $Id: rtcm3torinex.c,v 1.30 2010/01/16 10:21:09 mervart Exp $
   Copyright (C) 2005-2008 by Dirk Stöcker <stoecker@alberding.eu>
 
@@ -55,5 +55,5 @@
 
 /* CVS revision and version */
-static char revisionstr[] = "$Revision: 1.28 $";
+static char revisionstr[] = "$Revision: 1.30 $";
 
 #ifndef COMPILEDATE
@@ -251,8 +251,9 @@
 }
 
-void updatetime(int *week, int *tow, int tk, int fixnumleap)
+// Convert Moscow time into UTC (fixnumleap == 1) or GPS (fixnumleap == 0)
+void updatetime(int *week, int *secOfWeek, int mSecOfWeek, int fixnumleap)
 {
   int y,m,d,k,l, nul;
-  unsigned int j = *week*(7*24*60*60) + *tow + 5*24*60*60+3*60*60;
+  unsigned int j = *week*(7*24*60*60) + *secOfWeek + 5*24*60*60+3*60*60;
   int glo_daynumber = 0, glo_timeofday;
   for(y = 1980; j >= (unsigned int)(k = (l = (365+longyear(y,0)))*24*60*60)
@@ -272,13 +273,13 @@
   glo_timeofday = j-nul;
 
-  if(tk < 5*60*1000 && glo_timeofday > 23*60*60)
-    *tow += 24*60*60;
-  else if(glo_timeofday < 5*60 && tk > 23*60*60*1000)
-    *tow -= 24*60*60;
-  *tow += tk/1000-glo_timeofday;
+  if(mSecOfWeek < 5*60*1000 && glo_timeofday > 23*60*60)
+    *secOfWeek += 24*60*60;
+  else if(glo_timeofday < 5*60 && mSecOfWeek > 23*60*60*1000)
+    *secOfWeek -= 24*60*60;
+  *secOfWeek += mSecOfWeek/1000-glo_timeofday;
   if(fixnumleap)
-    *tow -= nul;
-  if(*tow < 0) {*tow += 24*60*60*7; --*week; }
-  if(*tow >= 24*60*60*7) {*tow -= 24*60*60*7; ++*week; }
+    *secOfWeek -= nul;
+  if(*secOfWeek < 0) {*secOfWeek += 24*60*60*7; --*week; }
+  if(*secOfWeek >= 24*60*60*7) {*secOfWeek -= 24*60*60*7; ++*week; }
 }
 
@@ -639,6 +640,6 @@
         GETBITS(i,27) /* tk */
 
-        updatetime(&handle->GPSWeek, &handle->GPSTOW, i, 0);
         i = handle->GPSTOW*1000;
+        updatetime(&handle->GPSWeek, &handle->GPSTOW, i, 0); // Moscow -> GPS
         if(gnss->week && (gnss->timeofweek != i || gnss->week
         != handle->GPSWeek))
@@ -1396,5 +1397,5 @@
             struct converttimeinfo cti;
 
-            updatetime(&w, &tow, e->tb*1000, 1);
+            updatetime(&w, &tow, e->tb*1000, 1);  // Moscow - > UTC
             converttime(&cti, w, tow);
 
@@ -1683,5 +1684,5 @@
 
 #ifndef NO_RTCM3_MAIN
-static char datestr[]     = "$Date: 2010/01/12 12:13:23 $";
+static char datestr[]     = "$Date: 2010/01/16 10:21:09 $";
 
 /* The string, which is send as agent in HTTP request */
