File indexing completed on 2024-04-28 05:42:09
0001 /* 0002 * Port for usage with qt-framework and development for kdesvn 0003 * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de) 0004 * https://kde.org/applications/development/org.kde.kdesvn 0005 */ 0006 /* 0007 * ==================================================================== 0008 * Copyright (c) 2002-2005 The RapidSvn Group. All rights reserved. 0009 * dev@rapidsvn.tigris.org 0010 * 0011 * This library is free software; you can redistribute it and/or 0012 * modify it under the terms of the GNU Lesser General Public 0013 * License as published by the Free Software Foundation; either 0014 * version 2.1 of the License, or (at your option) any later version. 0015 * 0016 * This library is distributed in the hope that it will be useful, 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0019 * Lesser General Public License for more details. 0020 * 0021 * You should have received a copy of the GNU Lesser General Public 0022 * License along with this library (in the file LGPL.txt); if not, 0023 * write to the Free Software Foundation, Inc., 51 Franklin St, 0024 * Fifth Floor, Boston, MA 02110-1301 USA 0025 * 0026 * This software consists of voluntary contributions made by many 0027 * individuals. For exact contribution history, see the revision 0028 * history and logs, available at http://rapidsvn.tigris.org/. 0029 * ==================================================================== 0030 */ 0031 0032 #ifndef SVNQT_DATETIME_H 0033 #define SVNQT_DATETIME_H 0034 0035 #include <svnqt/svnqt_defines.h> 0036 0037 #include <QDateTime> 0038 0039 // subversion api 0040 #include <svn_types.h> 0041 0042 namespace svn 0043 { 0044 /** 0045 * Class that encapsulates apr_time_t. 0046 * 0047 * @see apr_time_t 0048 */ 0049 class SVNQT_EXPORT DateTime 0050 { 0051 private: 0052 QDateTime m_time; 0053 0054 public: 0055 /** 0056 * Default Constructor 0057 */ 0058 DateTime(); 0059 0060 /** 0061 * Constructor 0062 * 0063 * @param time number of microseconds since 00:00:00 january 1, 1970 UTC 0064 */ 0065 explicit DateTime(const apr_time_t time); 0066 0067 /** 0068 * Constructor 0069 * 0070 * @param dt QDateTime class 0071 */ 0072 explicit DateTime(const QDateTime &dt); 0073 0074 /** 0075 * Constructor 0076 * @param dt RFC822 compatible string 0077 */ 0078 explicit DateTime(const QString &dt); 0079 0080 /** 0081 * @return Is a valid (non-zero) date 0082 */ 0083 bool IsValid() const 0084 { 0085 return m_time.isValid(); 0086 } 0087 0088 /** 0089 * @return APR apr_time_t 0090 */ 0091 apr_time_t GetAPRTimeT() const; 0092 0093 /** 0094 * @return QDateTime object 0095 */ 0096 const QDateTime &toQDateTime() const 0097 { 0098 return m_time; 0099 } 0100 0101 /** 0102 * @param format format string 0103 * @return formatted string 0104 * @see QDateTime::toString 0105 */ 0106 QString toString(const QString &format) const; 0107 QString toString(Qt::DateFormat f = Qt::DefaultLocaleShortDate) const; 0108 0109 /** 0110 * Set from date string of the form below, using apr_date_parse_rfc 0111 * 0112 * <PRE> 0113 * Sun, 06 Nov 1994 08:49:37 GMT 0114 * </PRE> 0115 * 0116 * @see apr_date_parse_rfc 0117 * @return Successfully parsed 0118 */ 0119 bool SetRFC822Date(const char *date); 0120 0121 void setAprTime(apr_time_t aTime); 0122 // unsigned int toTime_t()const; 0123 // void setTime_t(unsigned int sec); 0124 }; 0125 } 0126 0127 #endif 0128 /* ----------------------------------------------------------------- 0129 * local variables: 0130 * eval: (load-file "../../rapidsvn-dev.el") 0131 * end: 0132 */