Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/MbsAPI/f_ut_utime.c

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "typedefs.h"
00017 /*****************+***********+****************************************/
00018 /*                                                                    */
00019 /*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
00020 /*   Postfach 11 05 52                                                */
00021 /*   D-64220 Darmstadt                                                */
00022 /*                                                                    */
00023 /*1+ C Procedure *************+****************************************/
00024 /*                                                                    */
00025 /*+ Module      : f_ut_utime                                         */
00026 /*                                                                    */
00027 /*--------------------------------------------------------------------*/
00028 /*+ CALLING     : char * = f_ut_utime(l_sec,l_msec,char *pc_time)    */
00029 /*--------------------------------------------------------------------*/
00030 /*                                                                    */
00031 /*+ PURPOSE     : Returns date/time string in VMS format              */
00032 /*                  day-month-year hours:min:sec.00                   */
00033 /*                                                                    */
00034 /*+ ARGUMENTS   :                                                     */
00035 /*                                                                    */
00036 /*+   l_sec     : Seconds as returned from ftime function             */
00037 /*+   l_msec    : Milliseconds                                        */
00038 /*+  pc_time    : Address of string (23 characters)                   */
00039 /*                                                                    */
00040 /*2+Implementation************+****************************************/
00041 /*+ Utility     : util                                                */
00042 /*+ File name   : f_ut_utime.c                                       */
00043 /*+ Home direct.: path                                                */
00044 /*+ Declaration : char *f_ut_utime(char *);                          */
00045 /*+ Version     : 1.01                                                */
00046 /*+ Author      : H.G.Essel                                           */
00047 /*+ Created     : 24-Mar-1994                                         */
00048 /*+ Object libr.:                                                     */
00049 /*+ Updates     : Date        Purpose                                 */
00050 /*-               14-apr-97 : POSIX now OK on Lynx /HE                */
00051 /*                            gcc -mposix4d9 -mthreads -DLynx         */
00052 /*1- C Procedure *************+****************************************/
00053 #ifdef Lynx
00054 #include <sys/types.h>
00055 #include <timeb.h>
00056 #else
00057 #include <sys/types.h>
00058 #include <sys/timeb.h>
00059 #endif
00060 #include <stdio.h>
00061 #include <time.h>
00062 #include <string.h>
00063 
00064 INTS4 f_ut_utime(INTS4 l_sec, INTS4 l_msec, CHARS *pc_time)
00065 {
00066 
00067   time_t t_time;
00068   struct timeb tp;
00069   struct tm st_time;
00070   CHARS c_allmon[37]="JanFebMarAprMayJunJulAugSepOctNovDec";
00071   CHARS c_mon[4];
00072   CHARS *pc_mon;
00073 
00074   if(l_sec == 0)
00075   {
00076     strcpy(pc_time,"no valid date");
00077 #ifdef VMS
00078     return(1);
00079 #else
00080     return(0);
00081 #endif
00082   }
00083   *pc_time=0;
00084   ftime(&tp);
00085   if(l_sec > 0)
00086   {
00087     tp.time = l_sec;
00088 /*
00089 #ifdef VMS
00090     tp.time = l_sec + 7200;
00091 #endif
00092 */
00093 #ifdef xxxLynx
00094     tp.time = l_sec + 86400; /* one day */
00095 #endif
00096     tp.millitm = l_msec;
00097   }
00098 #ifdef xxxLynx
00099   localtime_r(&st_time,&tp.time);
00100   if(st_time.tm_mon > 2 && st_time.tm_mon < 9)    /* daylight saving ? */
00101   {
00102     tp.time+=3600;
00103     localtime_r(&st_time,&tp.time);
00104   }
00105 #else
00106   st_time = *localtime(&tp.time);
00107 #endif
00108   pc_mon = (CHARS *) &c_allmon;
00109   pc_mon += (st_time.tm_mon * 3);
00110   strncpy(c_mon,pc_mon,3);
00111   c_mon[3]='\0';
00112   if(st_time.tm_year < 100)
00113   sprintf(pc_time,"%02d-%s-19%02d %02d:%02d:%02d.%02d"
00114     ,st_time.tm_mday
00115     ,c_mon
00116     ,st_time.tm_year
00117     ,st_time.tm_hour
00118     ,st_time.tm_min
00119     ,st_time.tm_sec
00120     ,l_msec/10);
00121   else
00122   sprintf(pc_time,"%02d-%s-20%02d %02d:%02d:%02d.%02d"
00123     ,st_time.tm_mday
00124     ,c_mon
00125     ,st_time.tm_year-100
00126     ,st_time.tm_hour
00127     ,st_time.tm_min
00128     ,st_time.tm_sec
00129     ,l_msec/10);
00130 #ifdef VMS
00131   return(1);
00132 #else
00133   return(0);
00134 #endif
00135 }
00136 
00137 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:08 2005 for Go4-v2.10-5 by doxygen1.2.15