libDwm-0.9.45
DwmTimeUtil.hh
Go to the documentation of this file.
1//===========================================================================
2// @(#) $DwmPath$
3//===========================================================================
4// Copyright (c) Daniel W. McRobb 1999-2007
5// All rights reserved.
6//
7// Redistribution and use in source and binary forms, with or without
8// modification, are permitted provided that the following conditions
9// are met:
10//
11// 1. Redistributions of source code must retain the above copyright
12// notice, this list of conditions and the following disclaimer.
13// 2. Redistributions in binary form must reproduce the above copyright
14// notice, this list of conditions and the following disclaimer in the
15// documentation and/or other materials provided with the distribution.
16// 3. The names of the authors and copyright holders may not be used to
17// endorse or promote products derived from this software without
18// specific prior written permission.
19//
20// IN NO EVENT SHALL DANIEL W. MCROBB BE LIABLE TO ANY PARTY FOR
21// DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
22// INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE,
23// EVEN IF DANIEL W. MCROBB HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
24// DAMAGE.
25//
26// THE SOFTWARE PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND
27// DANIEL W. MCROBB HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
28// UPDATES, ENHANCEMENTS, OR MODIFICATIONS. DANIEL W. MCROBB MAKES NO
29// REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER
30// IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31// WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
32// OR THAT THE USE OF THIS SOFTWARE WILL NOT INFRINGE ANY PATENT,
33// TRADEMARK OR OTHER RIGHTS.
34//===========================================================================
35
36//---------------------------------------------------------------------------
39//---------------------------------------------------------------------------
40
41#ifndef _DWMTIMEUTIL_HH_
42#define _DWMTIMEUTIL_HH_
43
44extern "C" {
45#include <time.h>
46#include <sys/time.h>
47}
48
49#include <string>
50
51namespace Dwm {
52
53 //--------------------------------------------------------------------------
54 // class TimeUtil
55 //--------------------------------------------------------------------------
57 //--------------------------------------------------------------------------
59 {
60 public:
61 //------------------------------------------------------------------------
64 //------------------------------------------------------------------------
65 static void GmTime(time_t unixsecs, struct tm & result);
66
67 //------------------------------------------------------------------------
70 //------------------------------------------------------------------------
71 static void LocalTime(time_t unixsecs, struct tm & result);
72
73 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
78 static bool SubtractTimeval(const struct timeval & lhs,
79 const struct timeval & rhs,
80 struct timeval & result);
81
82 //------------------------------------------------------------------------
96 //------------------------------------------------------------------------
97 static bool ParseDateTime(const std::string & dateTimeString,
98 struct tm & tm);
99
100 //------------------------------------------------------------------------
114 //------------------------------------------------------------------------
115 static bool ParseDateTime(const std::string & dateTimeString, time_t & t);
116
117 //------------------------------------------------------------------------
121 //------------------------------------------------------------------------
122 static time_t MidnightDaysLater(int daysLater);
123 };
124
125
126} // namespace Dwm
127
128#endif // _DWMTIMEUTIL_HH_
129
130//---------------------------- emacs settings -----------------------------
131// Local Variables:
132// mode: C++
133// tab-width: 2
134// indent-tabs-mode: nil
135// c-basic-offset: 2
136// End:
137//-------------------------------------------------------------------------
This class is just a collection of time utility functions.
Definition DwmTimeUtil.hh:59
static bool ParseDateTime(const std::string &dateTimeString, struct tm &tm)
Parses dateTimeString and stores the resulting time in tm.
static bool ParseDateTime(const std::string &dateTimeString, time_t &t)
Parses dateTimeString and stores the resulting time in t.
static void LocalTime(time_t unixsecs, struct tm &result)
This is just a convenient wrapper for localtime(time_t *) that stores the result in result.
static bool SubtractTimeval(const struct timeval &lhs, const struct timeval &rhs, struct timeval &result)
Subtracts rhs from lhs and places the result in result.
static void GmTime(time_t unixsecs, struct tm &result)
This is just a convenient wrapper for gmtime(time_t *) that stores the result in result.
static time_t MidnightDaysLater(int daysLater)
Returns the time for midnight (00:00) at the given daysLater.