summaryrefslogtreecommitdiffabout
path: root/kabc/vcard/DateValue.cpp
Unidiff
Diffstat (limited to 'kabc/vcard/DateValue.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/DateValue.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/kabc/vcard/DateValue.cpp b/kabc/vcard/DateValue.cpp
index c5c5c85..87c7007 100644
--- a/kabc/vcard/DateValue.cpp
+++ b/kabc/vcard/DateValue.cpp
@@ -19,12 +19,14 @@
19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22*/ 22*/
23 23
24#include <qregexp.h> 24#include <qregexp.h>
25//Added by qt3to4:
26#include <Q3CString>
25 27
26#include <kdebug.h> 28#include <kdebug.h>
27 29
28#include <VCardDefines.h> 30#include <VCardDefines.h>
29#include <VCardDateValue.h> 31#include <VCardDateValue.h>
30#include <VCardValue.h> 32#include <VCardValue.h>
@@ -102,13 +104,13 @@ DateValue::DateValue(const DateValue & x)
102 zoneHour_ = x.zoneHour_; 104 zoneHour_ = x.zoneHour_;
103 zoneMinute_ = x.zoneMinute_; 105 zoneMinute_ = x.zoneMinute_;
104 secFrac_ = x.secFrac_; 106 secFrac_ = x.secFrac_;
105 hasTime_ = x.hasTime_; 107 hasTime_ = x.hasTime_;
106} 108}
107 109
108DateValue::DateValue(const QCString & s) 110DateValue::DateValue(const Q3CString & s)
109 :Value(s) 111 :Value(s)
110{ 112{
111} 113}
112 114
113 DateValue & 115 DateValue &
114DateValue::operator = (DateValue & x) 116DateValue::operator = (DateValue & x)
@@ -117,13 +119,13 @@ DateValue::operator = (DateValue & x)
117 119
118 Value::operator = (x); 120 Value::operator = (x);
119 return *this; 121 return *this;
120} 122}
121 123
122 DateValue & 124 DateValue &
123DateValue::operator = (const QCString & s) 125DateValue::operator = (const Q3CString & s)
124{ 126{
125 Value::operator = (s); 127 Value::operator = (s);
126 return *this; 128 return *this;
127} 129}
128 130
129 bool 131 bool
@@ -151,14 +153,14 @@ DateValue::_parse()
151 // date = date-full-year ["-"] date-month ["-"] date-mday 153 // date = date-full-year ["-"] date-month ["-"] date-mday
152 // time = time-hour [":"] time-minute [":"] time-second [":"] 154 // time = time-hour [":"] time-minute [":"] time-second [":"]
153 // [time-secfrac] [time-zone] 155 // [time-secfrac] [time-zone]
154 156
155 int timeSep = strRep_.find('T'); 157 int timeSep = strRep_.find('T');
156 158
157 QCString dateStr; 159 Q3CString dateStr;
158 QCString timeStr; 160 Q3CString timeStr;
159 161
160 if (timeSep == -1) { 162 if (timeSep == -1) {
161 163
162 dateStr = strRep_; 164 dateStr = strRep_;
163 vDebug("Has date string \"" + dateStr + "\""); 165 vDebug("Has date string \"" + dateStr + "\"");
164 166
@@ -170,13 +172,13 @@ DateValue::_parse()
170 timeStr = strRep_.mid(timeSep + 1); 172 timeStr = strRep_.mid(timeSep + 1);
171 vDebug("Has time string \"" + timeStr + "\""); 173 vDebug("Has time string \"" + timeStr + "\"");
172 } 174 }
173 175
174 /////////////////////////////////////////////////////////////// DATE 176 /////////////////////////////////////////////////////////////// DATE
175 177
176 dateStr.replace(QRegExp("-"), ""); 178 dateStr.replace("-", "");
177 179
178 kdDebug(5710) << "dateStr: " << dateStr << endl; 180 kdDebug(5710) << "dateStr: " << dateStr << endl;
179 181
180 year_= dateStr.left(4).toInt(); 182 year_= dateStr.left(4).toInt();
181 month_= dateStr.mid(4, 2).toInt(); 183 month_= dateStr.mid(4, 2).toInt();
182 day_= dateStr.right(2).toInt(); 184 day_= dateStr.right(2).toInt();
@@ -193,13 +195,13 @@ DateValue::_parse()
193 /////////////////////////////////////////////////////////////// ZONE 195 /////////////////////////////////////////////////////////////// ZONE
194 196
195 int zoneSep = timeStr.find('Z'); 197 int zoneSep = timeStr.find('Z');
196 198
197 if (zoneSep != -1 && timeStr.length() - zoneSep > 3) { 199 if (zoneSep != -1 && timeStr.length() - zoneSep > 3) {
198 200
199 QCString zoneStr(timeStr.mid(zoneSep + 1)); 201 Q3CString zoneStr(timeStr.mid(zoneSep + 1));
200 vDebug("zoneStr == " + zoneStr); 202 vDebug("zoneStr == " + zoneStr);
201 203
202 zonePositive_= (zoneStr[0] == '+'); 204 zonePositive_= (zoneStr[0] == '+');
203 zoneHour_ = zoneStr.mid(1, 2).toInt(); 205 zoneHour_ = zoneStr.mid(1, 2).toInt();
204 zoneMinute_ = zoneStr.right(2).toInt(); 206 zoneMinute_ = zoneStr.right(2).toInt();
205 207
@@ -208,47 +210,47 @@ DateValue::_parse()
208 210
209 //////////////////////////////////////////////////// SECOND FRACTION 211 //////////////////////////////////////////////////// SECOND FRACTION
210 212
211 int secFracSep = timeStr.findRev(','); 213 int secFracSep = timeStr.findRev(',');
212 214
213 if (secFracSep != -1 && zoneSep != -1) { // zoneSep checked to avoid errors. 215 if (secFracSep != -1 && zoneSep != -1) { // zoneSep checked to avoid errors.
214 QCString quirkafleeg = "0." + timeStr.mid(secFracSep + 1, zoneSep); 216 Q3CString quirkafleeg = "0." + timeStr.mid(secFracSep + 1, zoneSep);
215 secFrac_ = quirkafleeg.toDouble(); 217 secFrac_ = quirkafleeg.toDouble();
216 } 218 }
217 219
218 /////////////////////////////////////////////////////////////// HMS 220 /////////////////////////////////////////////////////////////// HMS
219 221
220 timeStr.replace(QRegExp(":"), ""); 222 timeStr.replace(":", "");
221 223
222 hour_= timeStr.left(2).toInt(); 224 hour_= timeStr.left(2).toInt();
223 minute_= timeStr.mid(2, 2).toInt(); 225 minute_= timeStr.mid(2, 2).toInt();
224 second_= timeStr.mid(4, 2).toInt(); 226 second_= timeStr.mid(4, 2).toInt();
225} 227}
226 228
227 void 229 void
228DateValue::_assemble() 230DateValue::_assemble()
229{ 231{
230 vDebug("DateValue::_assemble"); 232 vDebug("DateValue::_assemble");
231 233
232 QCString year; 234 Q3CString year;
233 QCString month; 235 Q3CString month;
234 QCString day; 236 Q3CString day;
235 237
236 year.setNum( year_ ); 238 year.setNum( year_ );
237 month.setNum( month_ ); 239 month.setNum( month_ );
238 day.setNum( day_ ); 240 day.setNum( day_ );
239 241
240 if ( month.length() < 2 ) month.prepend( "0" ); 242 if ( month.length() < 2 ) month.prepend( "0" );
241 if ( day.length() < 2 ) day.prepend( "0" ); 243 if ( day.length() < 2 ) day.prepend( "0" );
242 244
243 strRep_ = year + '-' + month + '-' + day; 245 strRep_ = year + '-' + month + '-' + day;
244 246
245 if ( hasTime_ ) { 247 if ( hasTime_ ) {
246 QCString hour; 248 Q3CString hour;
247 QCString minute; 249 Q3CString minute;
248 QCString second; 250 Q3CString second;
249 251
250 hour.setNum( hour_ ); 252 hour.setNum( hour_ );
251 minute.setNum( minute_ ); 253 minute.setNum( minute_ );
252 second.setNum( second_ ); 254 second.setNum( second_ );
253 255
254 if ( hour.length() < 2 ) hour.prepend( "0" ); 256 if ( hour.length() < 2 ) hour.prepend( "0" );