This file is indexed.

/usr/include/mama/MamaDateTime.h is in libmama-dev 2.2.2.1-11ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
/* $Id$
 *
 * OpenMAMA: The open middleware agnostic messaging API
 * Copyright (C) 2011 NYSE Technologies, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

#ifndef MamaDateTimeHpp__
#define MamaDateTimeHpp__

#include <mama/datetime.h>
#include <mama/MamaTimeZone.h>



namespace Wombat 
{

/**
 * A date/time representation with additional hints for precision,
 * advanced output formatting and support for time zone conversion
 * (using the MamaTimeZone type).
 *
 * Hints include: 
 *  - Whether the time stamp contains a date part, a time part, or both.
 *  - The level of accuracy (if known) of the time part (e.g., minutes, 
 *    seconds, milliseconds, etc.).
 *
 * The output format strings are similar to that available for the
 * strftime() function with the addition of %; which adds optional
 * (non-zero) fractional second to the string, and %: which adds
 * fractional seconds including trailing zeros, but does not include the ".".
 *  The following
 * table provides examples of output.<br>
 * <table>
 *   <tr>
 *     <th>Actual Time</th>
 *     <th>Output of "%T%;"</th>
 *     <th>Output of "%T%.:"</th>
 *   </tr>  
 *   <tr>
 *     <td>01:23:45 and 678 millisecs</td>
 *     <td>01:23:45.678</td>
 *     <td>01:23:45.678</td>
 *   </tr>
 *   <tr>
 *      <td>01:23:45 and 0 millisecs</td>
        <td>01:23:45</td>
        <td>01:23:45.000</td>
 *   </tr>
 * </table>
 */
class MAMACPPExpDLL MamaDateTime
{
public:
    MamaDateTime ();
    MamaDateTime (const MamaDateTime& copy);

    /**
     * Constructor taking a string argument.  This is the same as
     * calling setFromString() immediately after construction.
     */
    explicit MamaDateTime (const char*          str,
                           const MamaTimeZone*  tz = NULL);

    ~MamaDateTime ();

    MamaDateTime& operator=  (const MamaDateTime& rhs);
    bool          operator== (const MamaDateTime& rhs) const;
    bool          operator!= (const MamaDateTime& rhs) const
    { return ! operator== (rhs); }
    bool          operator<  (const MamaDateTime& rhs) const;
    bool          operator>  (const MamaDateTime& rhs) const;
    int           compare    (const MamaDateTime& rhs) const;
    bool          empty      () const;

    void          setEpochTime    (mama_u32_t             secondsSinceEpoch,
                                   mama_u32_t             microseconds,
                                   mamaDateTimePrecision  precision =
                                                  MAMA_DATE_TIME_PREC_UNKNOWN);
    void          setEpochTimeF64 (double                 secondsSinceEpoch);
    void          setEpochTimeMilliseconds (
                              mama_u64_t             millisecondsSinceEpoch);
    void          setEpochTimeMicroseconds (
                              mama_u64_t             microsecondsSinceEpoch);
    void          setWithHints    (mama_u32_t             secondsSinceEpoch,
                                   mama_u32_t             microseconds,
                                   mamaDateTimePrecision  precision =
                                                  MAMA_DATE_TIME_PREC_UNKNOWN,
                                   mamaDateTimeHints      hints = 0);
    void          setPrecision    (mamaDateTimePrecision  precision);
    void          setFromString   (const char*            str,
                                   const MamaTimeZone*    tz = NULL);
    void          setFromString   (const char*            str,
                                   mama_size_t            strLen,
                                   const MamaTimeZone*    tz = NULL);
    void          setToNow        ();
    void          setToMidnightToday (const MamaTimeZone*    tz = NULL);

    /**
     * Set the entire date and time for the MamaDateTime.  The year,
     * month and day parameters must all be integers greater than
     * zero.
     *
     * @param year          The year (must be 1970 or later).
     * @param month         The month (1 - 12).
     * @param day           The day (1 - 31).
     * @param hour          The hour (0 - 23).
     * @param minute        The minute (0 - 59).
     * @param second        The second (0 - 59).
     * @param microsecond   The second (0 - 999999).
     * @param precision     An explicit precision, if known.
     * @param tz            A timezone to shift from.
     */
    void set (
        mama_u32_t             year,
        mama_u32_t             month,
        mama_u32_t             day,
        mama_u32_t             hour,
        mama_u32_t             minute,
        mama_u32_t             second,
        mama_u32_t             microsecond,
        mamaDateTimePrecision  precision = MAMA_DATE_TIME_PREC_UNKNOWN,
        const MamaTimeZone*    tz = NULL);

    /**
     * Set the time-of-day portion of the MamaDateTime.  The date
     * portion is not affected.
     *
     * @param hour          The hour (0 - 23).
     * @param minute        The minute (0 - 59).
     * @param second        The second (0 - 59).
     * @param microsecond   The second (0 - 999999).
     * @param precision     An explicit precision, if known.
     * @param tz            A timezone to shift from.
     */
    void setTime (
        mama_u32_t             hour,
        mama_u32_t             minute,
        mama_u32_t             second,
        mama_u32_t             microsecond,
        mamaDateTimePrecision  precision = MAMA_DATE_TIME_PREC_UNKNOWN,
        const MamaTimeZone*    tz = NULL);

    /**
     * Set the date portion of the MamaDateTime.  The time-of-day
     * portion is not affected.  The year, month and day parameters
     * must all be integers greater than zero.
     *
     * @param year          The year (must be 1970 or later).
     * @param month         The month (1 - 12).
     * @param day           The day (1 - 31).
     */
    void setDate (
        mama_u32_t          year,
        mama_u32_t          month,
        mama_u32_t          day);

    /**
     * Copy the time-of-day portion of the MamaDateTime.  The date
     * portion is not affected.
     *
     * @param copy          The object to copy from
     */
    void copyTime (
        const MamaDateTime&  copy);

    /**
     * Copy the date portion of the MamaDateTime.  The time-of-day
     * portion is not affected.
     *
     * @param copy          The object to copy from
     */
    void copyDate (
        const MamaDateTime&  copy);

    /**
     * Clear the entire MamaDateTime.
     */
    void clear ();

    /**
     * Clear the time-of-day portion of the MamaDateTime.  The date
     * portion is not affected.
     */
    void clearTime ();

    /**
     * Clear the date portion of the MamaDateTime.  The time-of-day
     * portion is not affected.
     */
    void clearDate ();

    void          addSeconds      (mama_f64_t             seconds);
    void          addSeconds      (mama_i32_t             seconds);
    void          addMicroseconds (mama_i64_t             microSeconds);

	/**
	 * Get the date and time as microseconds since the Epoch, (using the UTC timezone).
	 *
	 * @return The number of microseconds since the Epoch.
	 */
    mama_u64_t    getEpochTimeMicroseconds () const;
	
	/**
	 * Get the date and time as microseconds since the Epoch in the supplied
	 * time zone.
	 *
	 * @param[int] tz The timezone.
	 * @return The number of microseconds since the Epoch.
	 */
    mama_u64_t    getEpochTimeMicroseconds (const MamaTimeZone&  tz) const;
    
    mama_u64_t    getEpochTimeMilliseconds () const;
    mama_u64_t    getEpochTimeMilliseconds (const MamaTimeZone&  tz) const;
    
    mama_f64_t    getEpochTimeSeconds      () const;
    mama_f64_t    getEpochTimeSeconds      (const MamaTimeZone&  tz) const;

	/**
	 * Get the date and time as seconds since the Epoch, (using the UTC timezone). 
	 * If no date value is contained in the dateTime then it will be set to today's date
	 * and the calculation made.
	 *	 
	 * @return The number of seconds, (including partial seconds), since the Epoch.
	 */
	mama_f64_t    getEpochTimeSecondsWithCheck() const;	
    
    void          getAsString     (char*        result,
                                   mama_size_t  maxLen) const;
    void          getTimeAsString (char*        result,
                                   mama_size_t  maxLen) const;
    void          getDateAsString (char*        result,
                                   mama_size_t  maxLen) const;

    /**
     * Return a string representation of the date/time.  Note that the
     * alternative getAsString() methods are more efficient because
     * these method must allocate a temporary buffer (automatically
     * destroyed upon object destruction).
     */
    const char*   getAsString     () const;
    const char*   getTimeAsString () const;
    const char*   getDateAsString () const;

    void          getAsFormattedString (char*                result,
                                        mama_size_t          maxLen,
                                        const char*          format) const;
    void          getAsFormattedString (char*                result,
                                        mama_size_t          maxLen,
                                        const char*          format,
                                        const MamaTimeZone&  tz) const;

    void          getAsStructTimeVal (struct timeval&       result) const;
    void          getAsStructTimeVal (struct timeval&       result,
                                      const MamaTimeZone&   tz) const;
                                      
    void          getAsStructTm      (struct tm&            result) const;
    void          getAsStructTm      (struct tm&            result,
                                      const MamaTimeZone&   tz) const;
                                      
    mama_u32_t    getYear        () const;
    mama_u32_t    getMonth       () const;
    mama_u32_t    getDay         () const;
    mama_u32_t    getHour        () const;
    mama_u32_t    getMinute      () const;
    mama_u32_t    getSecond      () const;
    mama_u32_t    getMicrosecond () const;
    mamaDayOfWeek getDayOfWeek   () const;

    /**
     * Return whether the object has a time component.
     */
    bool hasTime() const;

    /**
     * Return whether the object has a date component.
     */
    bool hasDate() const;

    mamaDateTime        getCValue();
    const mamaDateTime  getCValue() const;

private:
    mama_u64_t      mDateTime;
    mutable char*   mStrRep;
};

} // namespace Wombat


mama_f64_t  diffSeconds        (const Wombat::MamaDateTime&  t1,
                                const Wombat::MamaDateTime&  t0);

mama_f64_t  diffSecondsSameDay (const Wombat::MamaDateTime&  t1,
                                const Wombat::MamaDateTime&  t0);

mama_i64_t  diffMicroseconds   (const Wombat::MamaDateTime&  t1,
                                const Wombat::MamaDateTime&  t0);

#endif // MamaDateTimeHpp__