00001 // $Id: f_ut_time.c 1195 2014-04-10 11:22:09Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "typedefs.h" 00015 /*****************+***********+****************************************/ 00016 /* */ 00017 /* GSI, Gesellschaft fuer Schwerionenforschung mbH */ 00018 /* Postfach 11 05 52 */ 00019 /* D-64220 Darmstadt */ 00020 /* */ 00021 /*1+ C Procedure *************+****************************************/ 00022 /* */ 00023 /*+ Module : f_ut_time */ 00024 /* */ 00025 /*--------------------------------------------------------------------*/ 00026 /*+ CALLING : CHARS * = f_ut_time(CHARS *) */ 00027 /*--------------------------------------------------------------------*/ 00028 /* */ 00029 /*+ PURPOSE : Returns date/time string in format */ 00030 /* day-month-year hours:min:sec */ 00031 /* must be linked on Lynx with -X (=posix library) */ 00032 /* because of the time correction done. */ 00033 /* On VMS with /PREF=ALL */ 00034 /* */ 00035 /*3+Function******+***********+****************************************/ 00036 /* */ 00037 /* Length of returned string is 17. No \n. */ 00038 /* */ 00039 /*3+Examples******+***********+****************************************/ 00040 /* Description */ 00041 /*2+Implementation************+****************************************/ 00042 /*+ Utility : util */ 00043 /*+ File name : f_ut_time.c */ 00044 /*+ Home direct.: path */ 00045 /*+ Declaration : CHARS *f_ut_time(CHARS *); */ 00046 /*+ Version : 1.01 */ 00047 /*+ Author : H.G.Essel */ 00048 /*+ Created : 24-Mar-1994 */ 00049 /*+ Object libr.: */ 00050 /*+ Updates : Date Purpose */ 00051 /*- : 03-apr-97 : support VMS, AIX, DECunix, Lynx */ 00052 /*1- C Procedure *************+****************************************/ 00053 #ifdef Lynx 00054 #include <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 00063 CHARS *f_ut_time (CHARS *pc_time) 00064 { 00065 00066 time_t t_time; 00067 struct timeb tp; 00068 struct tm st_time; 00069 struct tm buf_time; 00070 00071 ftime (&tp); 00072 00073 #ifdef Lynx 00074 /* Note: due to an error in POSIX Version of localtime, 1 day has to be */ 00075 /* added to get the correct date. During daylight saving period 1 hour */ 00076 /* has to be added additionaly */ 00077 tp.time+=86400; /* add 1 day */ 00078 localtime_r(&st_time,&tp.time); 00079 if(st_time.tm_mon > 2 && st_time.tm_mon < 9) /* daylight saving ? */ 00080 { 00081 tp.time+=3600; 00082 localtime_r(&st_time,&tp.time); 00083 } 00084 #else 00085 st_time=*localtime_r(&tp.time, &buf_time); 00086 #endif 00087 00088 strftime(pc_time,30,"%d-%h-%y %T",&st_time); 00089 return ((CHARS *) pc_time); 00090 }