versadac  1
versadac - Scalable Recorder Firmware
am_timeformatter.h
1 /*****************************************************************************
2 FILE : am_timeformatter.h
3 VERSION : $Id: am_timeformatter.h 4938 2006-10-10 14:20:18Z martinto $
4 AUTHOR : Sandra Herring
5 SYSTEM : GNU C++ for Power PC
6 DESCRIPTION : Utilities for converting timestamps to text
7 *****************************************************************************/
8 
9 #if !defined(__AM_TIMEFORMATTER_H)
10 #define __AM_TIMEFORMATTER_H
11 
12 extern "C"
13 {
14 #include <time.h>
15 #include "stdtypes.h"
16 }
17 
18 class AM_Archiver;
19 class AM_Timezone;
20 
22 {
23  public :
24 
25 /*------------------------------------------------------------------------------
26 FUNCTION : AM_TimeFormatter constructor
27 ARGUMENTS : None.
28 ------------------------------------------------------------------------------*/
30 
31 /*------------------------------------------------------------------------------
32 FUNCTION : AM_TimeFormatter getDateFormat
33 DESCRIPTION : Instructs this object to obtain the date format from Java
34  so it is ready to convert dates.
35 ARGUMENTS : Archive route information.
36 RETURN : None.
37 NOTES :
38 ------------------------------------------------------------------------------*/
39  void getDateFormat( AM_Archiver & archiver );
40 
41 /*------------------------------------------------------------------------------
42 FUNCTION : AM_TimeFormatter utcToLocal
43 DESCRIPTION : Method to convert UTC time to local broken down time.
44 ARGUMENTS : Timestamp to convert. Structure for converted time.
45 RETURN : The updated structure.
46 NOTES :
47 ------------------------------------------------------------------------------*/
48  struct tm * utcToLocal( time_t utcTimeStamp,
49  struct tm * pLocalTime );
50 
51 /*------------------------------------------------------------------------------
52 FUNCTION : AM_TimeFormatter formatDate
53 DESCRIPTION : Method to generate date text.
54 ARGUMENTS : Timestamp to convert. Buffer for text.
55 RETURN : Text.
56 NOTES :
57 ------------------------------------------------------------------------------*/
58  const char * formatDate( time_t utcTimeStamp,
59  char * dest );
60 
61 /*------------------------------------------------------------------------------
62 FUNCTION : AM_TimeFormatter formatTime
63 DESCRIPTION : Method to generate time text.
64 ARGUMENTS : Timestamp to convert. Buffer for text.
65 RETURN : Text.
66 NOTES :
67 ------------------------------------------------------------------------------*/
68  const char * formatTime( time_t utcTimeStamp,
69  char * dest );
70 
71 /*------------------------------------------------------------------------------
72 FUNCTION : AM_TimeFormatter formatDateTime
73 DESCRIPTION : Method to generate timestamp text.
74 ARGUMENTS : Timestamp to convert. Buffer for text.
75 RETURN : Text.
76 NOTES :
77 ------------------------------------------------------------------------------*/
78  const char * formatDateTime( time_t utcTimeStamp,
79  char * dest );
80 
81 /*------------------------------------------------------------------------------
82 FUNCTION : AM_TimeFormatter formatAsSpreadsheet
83 DESCRIPTION : Method to generate timestamp text in spreadsheet format.
84 ARGUMENTS : Timestamp to convert. Buffer for text.
85  Optional string to be used instead of decimal point
86 RETURN : Text.
87 NOTES :
88 ------------------------------------------------------------------------------*/
89  const char * formatAsSpreadsheet( time_t utcTimeStamp,
90  char * dest,
91  const char * decimalChars );
92 
93 /*---------------------------------------------------------------------------
94 FUNCTION : setTimezone
95 DESCRIPTION : Specifies the time zone settings.
96 ARGUMENTS : Timezone information.
97 RETURN : None.
98 NOTES :
99 ---------------------------------------------------------------------------*/
100  void setTimezone( AM_Timezone * pTimezone );
101 
102  private :
103  const char * formatDateStruct( const struct tm & dateStruct,
104  char * dest );
105 
106  const char * formatTimeStruct( const struct tm & timeStruct,
107  char * dest );
108 
109  enum
110  {
111  DAY,
112  MONTH,
113  YEAR,
114  NUM_FIELDS
115  };
116 
117  AM_Timezone * m_pTimezone; // Timezone information
118  sint16 m_DateFields[NUM_FIELDS]; // Location of each date component
119  char m_DateSeparator; // Field separator character
120 
121 }; // class AM_TimeFormatter
122 
123 
124 // inline services for class AM_TimeFormatter
125 
126 /*---------------------------------------------------------------------------
127 FUNCTION : setTimezone
128 DESCRIPTION : Specifies the time zone settings.
129 ARGUMENTS : Timezone information.
130 RETURN : None.
131 NOTES :
132 ---------------------------------------------------------------------------*/
133 inline void AM_TimeFormatter::setTimezone( AM_Timezone * pTimezone )
134 {
135  m_pTimezone = pTimezone;
136 }
137 
138 #endif
139 
Definition: am_archiver.h:90
Definition: am_timezone.h:75
Definition: am_timeformatter.h:21