28 #include <VCardDefines.h>
29 #include <VCardDateValue.h>
30 #include <VCardValue.h>
32 using namespace VCARD;
34 DateValue::DateValue()
37 vDebug(
"DateValue::DateValue()");
49 unsigned int zoneHour,
50 unsigned int zoneMinute)
59 zoneMinute_ (zoneMinute),
61 zonePositive_ (zonePositive),
68 DateValue::DateValue(
const TQDate & d)
79 DateValue::DateValue(
const TQDateTime & d)
81 year_ (d.date().year()),
82 month_ (d.date().month()),
83 day_ (d.date().day()),
84 hour_ (d.time().hour()),
85 minute_ (d.time().minute()),
86 second_ (d.time().second()),
93 DateValue::DateValue(
const DateValue & x)
102 zoneHour_ = x.zoneHour_;
103 zoneMinute_ = x.zoneMinute_;
104 secFrac_ = x.secFrac_;
105 hasTime_ = x.hasTime_;
108 DateValue::DateValue(
const TQCString & s)
114 DateValue::operator = (DateValue & x)
116 if (*
this == x)
return *
this;
118 Value::operator = (x);
123 DateValue::operator = (
const TQCString & s)
125 Value::operator = (s);
130 DateValue::operator == (DateValue & x)
136 DateValue::~DateValue()
143 return new DateValue( *
this );
149 vDebug(
"DateValue::_parse()");
155 int timeSep = strRep_.find(
'T');
163 vDebug(
"Has date string \"" + dateStr +
"\"");
167 dateStr = strRep_.left(timeSep);
168 vDebug(
"Has date string \"" + dateStr +
"\"");
170 timeStr = strRep_.mid(timeSep + 1);
171 vDebug(
"Has time string \"" + timeStr +
"\"");
176 dateStr.replace(TQRegExp(
"-"),
"");
180 year_ = dateStr.left(4).toInt();
181 month_ = dateStr.mid(4, 2).toInt();
182 day_ = dateStr.right(2).toInt();
195 int zoneSep = timeStr.find(
'Z');
197 if (zoneSep != -1 && timeStr.length() - zoneSep > 3) {
199 TQCString zoneStr(timeStr.mid(zoneSep + 1));
200 vDebug(
"zoneStr == " + zoneStr);
202 zonePositive_ = (zoneStr[0] ==
'+');
203 zoneHour_ = zoneStr.mid(1, 2).toInt();
204 zoneMinute_ = zoneStr.right(2).toInt();
206 timeStr.remove(zoneSep, timeStr.length() - zoneSep);
211 int secFracSep = timeStr.findRev(
',');
213 if (secFracSep != -1 && zoneSep != -1) {
214 TQCString quirkafleeg =
"0." + timeStr.mid(secFracSep + 1, zoneSep);
215 secFrac_ = quirkafleeg.toDouble();
220 timeStr.replace(TQRegExp(
":"),
"");
222 hour_ = timeStr.left(2).toInt();
223 minute_ = timeStr.mid(2, 2).toInt();
224 second_ = timeStr.mid(4, 2).toInt();
228 DateValue::_assemble()
230 vDebug(
"DateValue::_assemble");
236 year.setNum( year_ );
237 month.setNum( month_ );
240 if ( month.length() < 2 ) month.prepend(
"0" );
241 if ( day.length() < 2 ) day.prepend(
"0" );
243 strRep_ = year +
'-' + month +
'-' + day;
250 hour.setNum( hour_ );
251 minute.setNum( minute_ );
252 second.setNum( second_ );
254 if ( hour.length() < 2 ) hour.prepend(
"0" );
255 if ( minute.length() < 2 ) minute.prepend(
"0" );
256 if ( second.length() < 2 ) second.prepend(
"0" );
258 strRep_ +=
'T' + hour +
':' + minute +
':' + second +
'Z';
304 DateValue::secondFraction()
311 DateValue::zonePositive()
314 return zonePositive_;
318 DateValue::zoneHour()
325 DateValue::zoneMinute()
332 DateValue::setYear(
unsigned int i)
339 DateValue::setMonth(
unsigned int i)
346 DateValue::setDay(
unsigned int i)
353 DateValue::setHour(
unsigned int i)
360 DateValue::setMinute(
unsigned int i)
367 DateValue::setSecond(
unsigned int i)
374 DateValue::setSecondFraction(
double d)
381 DateValue::setZonePositive(
bool b)
388 DateValue::setZoneHour(
unsigned int i)
395 DateValue::setZoneMinute(
unsigned int i)
405 TQDate d(year_, month_, day_);
413 TQTime t(hour_, minute_, second_);
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)