• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

kabc

  • sources
  • kde-4.12
  • kdepimlibs
  • kabc
timezone.cpp
1 /*
2  This file is part of libkabc.
3  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #include "timezone.h"
22 
23 #include <QtCore/QDataStream>
24 #include <QtCore/QSharedData>
25 
26 using namespace KABC;
27 
28 class TimeZone::Private : public QSharedData
29 {
30  public:
31  Private( int offset = 0, bool valid = false )
32  : mOffset( offset ), mValid( valid )
33  {
34  }
35 
36  Private( const Private &other )
37  : QSharedData( other )
38  {
39  mOffset = other.mOffset;
40  mValid = other.mValid;
41  }
42 
43  int mOffset;
44  bool mValid;
45 };
46 
47 TimeZone::TimeZone()
48  : d( new Private )
49 {
50 }
51 
52 TimeZone::TimeZone( int offset )
53  : d( new Private( offset, true ) )
54 {
55 }
56 
57 TimeZone::TimeZone( const TimeZone &other )
58  : d( other.d )
59 {
60 }
61 
62 TimeZone::~TimeZone()
63 {
64 }
65 
66 void TimeZone::setOffset( int offset )
67 {
68  d->mOffset = offset;
69  d->mValid = true;
70 }
71 
72 int TimeZone::offset() const
73 {
74  return d->mOffset;
75 }
76 
77 bool TimeZone::isValid() const
78 {
79  return d->mValid;
80 }
81 
82 bool TimeZone::operator==( const TimeZone &t ) const
83 {
84  if ( !t.isValid() && !isValid() ) {
85  return true;
86  }
87 
88  if ( !t.isValid() || !isValid() ) {
89  return false;
90  }
91 
92  if ( t.d->mOffset == d->mOffset ) {
93  return true;
94  }
95 
96  return false;
97 }
98 
99 bool TimeZone::operator!=( const TimeZone &t ) const
100 {
101  return !( *this == t );
102 }
103 
104 TimeZone &TimeZone::operator=( const TimeZone &other )
105 {
106  if ( this != &other ) {
107  d = other.d;
108  }
109 
110  return *this;
111 }
112 
113 QString TimeZone::toString() const
114 {
115  QString str;
116 
117  str += QString::fromLatin1( "TimeZone {\n" );
118  str += QString::fromLatin1( " Offset: %1\n" ).arg( d->mOffset );
119  str += QString::fromLatin1( "}\n" );
120 
121  return str;
122 }
123 
124 QDataStream &KABC::operator<<( QDataStream &s, const TimeZone &zone )
125 {
126  return s << zone.d->mOffset << zone.d->mValid;
127 }
128 
129 QDataStream &KABC::operator>>( QDataStream &s, TimeZone &zone )
130 {
131  s >> zone.d->mOffset >> zone.d->mValid;
132 
133  return s;
134 }
KABC::TimeZone::setOffset
void setOffset(int offset)
Set time zone offset relative to UTC.
Definition: timezone.cpp:66
KABC::TimeZone::isValid
bool isValid() const
Return, if this time zone object is valid.
Definition: timezone.cpp:77
KABC::TimeZone::offset
int offset() const
Return offset in minutes relative to UTC.
Definition: timezone.cpp:72
KABC::TimeZone::TimeZone
TimeZone()
Construct invalid time zone.
Definition: timezone.cpp:47
KABC::TimeZone
Time zone information.
Definition: timezone.h:35
KABC::TimeZone::~TimeZone
~TimeZone()
Destroys the time zone.
Definition: timezone.cpp:62
KABC::TimeZone::toString
QString toString() const
Return string representation of time zone offset.
Definition: timezone.cpp:113
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:01:05 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kabc

Skip menu "kabc"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal