GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
f_ut_time.c
Go to the documentation of this file.
1 // $Id: f_ut_time.c 1355 2015-01-27 14:28:43Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "typedefs.h"
15 /*****************+***********+****************************************/
16 /* */
17 /* GSI, Gesellschaft fuer Schwerionenforschung mbH */
18 /* Postfach 11 05 52 */
19 /* D-64220 Darmstadt */
20 /* */
21 /*1+ C Procedure *************+****************************************/
22 /* */
23 /*+ Module : f_ut_time */
24 /* */
25 /*--------------------------------------------------------------------*/
26 /*+ CALLING : CHARS * = f_ut_time(CHARS *) */
27 /*--------------------------------------------------------------------*/
28 /* */
29 /*+ PURPOSE : Returns date/time string in format */
30 /* day-month-year hours:min:sec */
31 /* must be linked on Lynx with -X (=posix library) */
32 /* because of the time correction done. */
33 /* On VMS with /PREF=ALL */
34 /* */
35 /*3+Function******+***********+****************************************/
36 /* */
37 /* Length of returned string is 17. No \n. */
38 /* */
39 /*3+Examples******+***********+****************************************/
40 /* Description */
41 /*2+Implementation************+****************************************/
42 /*+ Utility : util */
43 /*+ File name : f_ut_time.c */
44 /*+ Home direct.: path */
45 /*+ Declaration : CHARS *f_ut_time(CHARS *); */
46 /*+ Version : 1.01 */
47 /*+ Author : H.G.Essel */
48 /*+ Created : 24-Mar-1994 */
49 /*+ Object libr.: */
50 /*+ Updates : Date Purpose */
51 /*- : 03-apr-97 : support VMS, AIX, DECunix, Lynx */
52 /*1- C Procedure *************+****************************************/
53 #ifdef Lynx
54 #include <types.h>
55 #include <timeb.h>
56 #else
57 #include <sys/types.h>
58 #include <sys/timeb.h>
59 #endif
60 #include <stdio.h>
61 #include <time.h>
62 
63 CHARS *f_ut_time (CHARS *pc_time)
64 {
65 
66  time_t t_time;
67  struct timeb tp;
68  struct tm st_time;
69  struct tm buf_time;
70 
71  ftime (&tp);
72 
73 #ifdef Lynx
74 /* Note: due to an error in POSIX Version of localtime, 1 day has to be */
75 /* added to get the correct date. During daylight saving period 1 hour */
76 /* has to be added additionaly */
77  tp.time+=86400; /* add 1 day */
78  localtime_r(&st_time,&tp.time);
79  if(st_time.tm_mon > 2 && st_time.tm_mon < 9) /* daylight saving ? */
80  {
81  tp.time+=3600;
82  localtime_r(&st_time,&tp.time);
83  }
84 #else
85 #ifdef WIN32
86  st_time=*localtime(&tp.time);
87 #else
88  st_time=*localtime_r(&tp.time, &buf_time);
89 #endif
90 #endif
91  strftime(pc_time,30,"%d-%h-%y %T",&st_time);
92  return ((CHARS *) pc_time);
93 }
CHARS * f_ut_time(CHARS *pc_time)
Definition: f_ut_time.c:63
char CHARS
Definition: typedefs.h:21