235 |
21 Apr 07 |
peter |
1 |
#ifndef _theplu_svndigest_date_ |
235 |
21 Apr 07 |
peter |
2 |
#define _theplu_svndigest_date_ |
235 |
21 Apr 07 |
peter |
3 |
|
235 |
21 Apr 07 |
peter |
// $Id$ |
235 |
21 Apr 07 |
peter |
5 |
|
235 |
21 Apr 07 |
peter |
6 |
/* |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2007 Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
235 |
21 Apr 07 |
peter |
9 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
235 |
21 Apr 07 |
peter |
11 |
|
235 |
21 Apr 07 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
235 |
21 Apr 07 |
peter |
under the terms of the GNU General Public License as published by |
693 |
11 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
235 |
21 Apr 07 |
peter |
(at your option) any later version. |
235 |
21 Apr 07 |
peter |
16 |
|
235 |
21 Apr 07 |
peter |
svndigest is distributed in the hope that it will be useful, but |
235 |
21 Apr 07 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
235 |
21 Apr 07 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
235 |
21 Apr 07 |
peter |
General Public License for more details. |
235 |
21 Apr 07 |
peter |
21 |
|
235 |
21 Apr 07 |
peter |
You should have received a copy of the GNU General Public License |
693 |
11 Sep 08 |
jari |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
235 |
21 Apr 07 |
peter |
24 |
*/ |
235 |
21 Apr 07 |
peter |
25 |
|
235 |
21 Apr 07 |
peter |
26 |
#include <ctime> |
235 |
21 Apr 07 |
peter |
27 |
#include <vector> |
235 |
21 Apr 07 |
peter |
28 |
#include <string> |
235 |
21 Apr 07 |
peter |
29 |
|
235 |
21 Apr 07 |
peter |
30 |
namespace theplu{ |
235 |
21 Apr 07 |
peter |
31 |
namespace svndigest{ |
235 |
21 Apr 07 |
peter |
32 |
|
235 |
21 Apr 07 |
peter |
33 |
/// |
1513 |
23 Sep 12 |
peter |
/// Class taking care of time and date handling. |
235 |
21 Apr 07 |
peter |
35 |
/// |
1513 |
23 Sep 12 |
peter |
36 |
class Date |
235 |
21 Apr 07 |
peter |
37 |
{ |
235 |
21 Apr 07 |
peter |
38 |
public: |
235 |
21 Apr 07 |
peter |
39 |
/// |
235 |
21 Apr 07 |
peter |
/// @brief Constructor |
235 |
21 Apr 07 |
peter |
41 |
/// |
235 |
21 Apr 07 |
peter |
42 |
Date(void); |
235 |
21 Apr 07 |
peter |
43 |
|
235 |
21 Apr 07 |
peter |
44 |
/// |
235 |
21 Apr 07 |
peter |
/// @brief Copy Constructor |
235 |
21 Apr 07 |
peter |
46 |
/// |
235 |
21 Apr 07 |
peter |
47 |
Date(const Date&); |
235 |
21 Apr 07 |
peter |
48 |
|
235 |
21 Apr 07 |
peter |
49 |
/// |
235 |
21 Apr 07 |
peter |
/// @brief Constructor from svn date string |
235 |
21 Apr 07 |
peter |
51 |
/// |
235 |
21 Apr 07 |
peter |
/// @see svntime(std::string) |
235 |
21 Apr 07 |
peter |
53 |
/// |
235 |
21 Apr 07 |
peter |
54 |
Date(std::string); |
235 |
21 Apr 07 |
peter |
55 |
|
235 |
21 Apr 07 |
peter |
56 |
/// |
235 |
21 Apr 07 |
peter |
/// @return string describing distance between two dates |
235 |
21 Apr 07 |
peter |
58 |
/// |
235 |
21 Apr 07 |
peter |
59 |
std::string difftime(const Date& other) const; |
235 |
21 Apr 07 |
peter |
60 |
|
235 |
21 Apr 07 |
peter |
61 |
/// |
235 |
21 Apr 07 |
peter |
/// @brief sets time to gmtime |
235 |
21 Apr 07 |
peter |
63 |
/// |
235 |
21 Apr 07 |
peter |
64 |
void gmtime(void); |
235 |
21 Apr 07 |
peter |
65 |
|
235 |
21 Apr 07 |
peter |
66 |
/// |
235 |
21 Apr 07 |
peter |
/// @brief sets time to local time |
235 |
21 Apr 07 |
peter |
68 |
/// |
235 |
21 Apr 07 |
peter |
69 |
void localtime(void); |
235 |
21 Apr 07 |
peter |
70 |
|
235 |
21 Apr 07 |
peter |
71 |
/// |
235 |
21 Apr 07 |
peter |
/// \brief sets time from a svn time string |
235 |
21 Apr 07 |
peter |
73 |
/// |
235 |
21 Apr 07 |
peter |
/// \parameter str string in format 2006-09-09T10:55:52.132733Z |
235 |
21 Apr 07 |
peter |
75 |
/// |
235 |
21 Apr 07 |
peter |
76 |
void svntime(std::string str); |
235 |
21 Apr 07 |
peter |
77 |
|
235 |
21 Apr 07 |
peter |
78 |
/// |
235 |
21 Apr 07 |
peter |
/// \return seconds since 00:00:00 Jan 1 1970 |
235 |
21 Apr 07 |
peter |
80 |
/// |
235 |
21 Apr 07 |
peter |
81 |
inline time_t seconds(void) const { return time_; } |
235 |
21 Apr 07 |
peter |
82 |
|
235 |
21 Apr 07 |
peter |
83 |
/// |
235 |
21 Apr 07 |
peter |
/// \a format sets the format of the returned string. Supported |
235 |
21 Apr 07 |
peter |
/// parameters are: |
1513 |
23 Sep 12 |
peter |
/// %a - short string of weekday e.g. Wed |
235 |
21 Apr 07 |
peter |
/// %A - long string of weekday e.g. Wednesday |
1513 |
23 Sep 12 |
peter |
/// %b - short string of month e.g. Apr |
235 |
21 Apr 07 |
peter |
/// %B - long string of weekday e.g. April |
235 |
21 Apr 07 |
peter |
/// %d - day of month integer e.g. 9 |
235 |
21 Apr 07 |
peter |
/// %e - day of month integer e.g. 09 |
235 |
21 Apr 07 |
peter |
/// %H - hours [0,23] |
235 |
21 Apr 07 |
peter |
/// %I - hours [1,12] |
235 |
21 Apr 07 |
peter |
/// %j - day of the year [1,366] |
235 |
21 Apr 07 |
peter |
/// %m - month integer e.g. 04 |
235 |
21 Apr 07 |
peter |
/// %M - minutes after the hour [0,59] |
235 |
21 Apr 07 |
peter |
/// %P - AM or PM |
235 |
21 Apr 07 |
peter |
/// %S - seconds efter the minute [0,59] |
235 |
21 Apr 07 |
peter |
/// %w - day of week [1,7] Sunday is 7 |
235 |
21 Apr 07 |
peter |
/// %y - year in two digits |
235 |
21 Apr 07 |
peter |
/// %Y - year in four digits |
235 |
21 Apr 07 |
peter |
/// %Z - timezone abbrevation |
235 |
21 Apr 07 |
peter |
103 |
/// |
1513 |
23 Sep 12 |
peter |
/// \return date and time |
235 |
21 Apr 07 |
peter |
105 |
/// |
235 |
21 Apr 07 |
peter |
106 |
std::string operator()(std::string format) const; |
235 |
21 Apr 07 |
peter |
107 |
|
235 |
21 Apr 07 |
peter |
108 |
/// |
235 |
21 Apr 07 |
peter |
/// @brief assignment operator |
235 |
21 Apr 07 |
peter |
110 |
/// |
235 |
21 Apr 07 |
peter |
/// @return const reference to assigned Date |
235 |
21 Apr 07 |
peter |
112 |
/// |
235 |
21 Apr 07 |
peter |
113 |
const Date& operator=(const Date&); |
235 |
21 Apr 07 |
peter |
114 |
|
235 |
21 Apr 07 |
peter |
115 |
/// |
235 |
21 Apr 07 |
peter |
/// @return true if lhs is earlier than \a rhs |
235 |
21 Apr 07 |
peter |
117 |
/// |
1513 |
23 Sep 12 |
peter |
118 |
inline bool operator<(const Date& rhs) const |
235 |
21 Apr 07 |
peter |
119 |
{ return time_<rhs.time_; } |
235 |
21 Apr 07 |
peter |
120 |
|
235 |
21 Apr 07 |
peter |
121 |
private: |
235 |
21 Apr 07 |
peter |
122 |
time_t time_; |
235 |
21 Apr 07 |
peter |
123 |
}; |
235 |
21 Apr 07 |
peter |
124 |
|
235 |
21 Apr 07 |
peter |
125 |
}} |
235 |
21 Apr 07 |
peter |
126 |
#endif |