summaryrefslogtreecommitdiffstats
path: root/libkdeedu/extdate/extdatetime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libkdeedu/extdate/extdatetime.cpp')
-rw-r--r--libkdeedu/extdate/extdatetime.cpp136
1 files changed, 69 insertions, 67 deletions
diff --git a/libkdeedu/extdate/extdatetime.cpp b/libkdeedu/extdate/extdatetime.cpp
index fe32cf91..2af13595 100644
--- a/libkdeedu/extdate/extdatetime.cpp
+++ b/libkdeedu/extdate/extdatetime.cpp
@@ -77,7 +77,7 @@ TQString ExtDate::m_longDayNames[7] = {
ExtDate::ExtDate( int y, int m, int d)
{
if ( !isValid(y,m,d) ) {
-#if defined(QT_CHECK_RANGE)
+#if defined(TQT_CHECK_RANGE)
qWarning( "ExtDate: Invalid date %04d-%02d-%02d", y, m, d );
#endif
m_year = 0;
@@ -232,20 +232,20 @@ int ExtDate::weekNumber( int *yearNum ) const
return week;
}
-#ifndef QT_NO_TEXTDATE
+#ifndef TQT_NO_TEXTDATE
TQString ExtDate::shortMonthName( int month ) {return m_shortMonthNames[month-1];}
TQString ExtDate::shortDayName( int weekday ) {return m_shortDayNames[weekday-1];}
TQString ExtDate::longMonthName( int month ) {return m_longMonthNames[month-1];}
TQString ExtDate::longDayName( int weekday ) {return m_longDayNames[weekday-1];}
-#endif //QT_NO_TEXTDATE
+#endif //TQT_NO_TEXTDATE
-#ifndef QT_NO_TEXTSTRING
-#if !defined(QT_NO_SPRINTF)
+#ifndef TQT_NO_TEXTSTRING
+#if !defined(TQT_NO_SPRINTF)
TQString ExtDate::toString( Qt::DateFormat f) const
{
- QString a_format;
+ TQString a_format;
- if ( ! isValid() ) return TQString::null;
+ if ( ! isValid() ) return TQString();
switch (f)
{
@@ -272,7 +272,7 @@ TQString ExtDate::toString( Qt::DateFormat f) const
TQString ExtDate::toString( const TQString& format ) const
{
- if ( ! isValid() ) return TQString::null;
+ if ( ! isValid() ) return TQString();
//We use the KDE Date format specs.
//Replace occurences of the following tokens with their
@@ -293,16 +293,16 @@ TQString ExtDate::toString( const TQString& format ) const
TQString result( format );
- result.replace( "%Y", TQString().sprintf( "%d", year() ) );
- result.replace( "%y", TQString().sprintf( "%02d", (year() % 100) ) );
- result.replace( "%n", TQString().sprintf( "%d", month() ) );
- result.replace( "%m", TQString().sprintf( "%02d", month() ) );
- result.replace( "%e", TQString().sprintf( "%d", day() ) );
- result.replace( "%d", TQString().sprintf( "%02d", day() ) );
- result.replace( "%b", shortMonthName( month() ) );
- result.replace( "%B", longMonthName( month() ) );
- result.replace( "%a", shortDayName( dayOfWeek() ) );
- result.replace( "%A", longDayName( dayOfWeek() ) );
+ result.tqreplace( "%Y", TQString().sprintf( "%d", year() ) );
+ result.tqreplace( "%y", TQString().sprintf( "%02d", (year() % 100) ) );
+ result.tqreplace( "%n", TQString().sprintf( "%d", month() ) );
+ result.tqreplace( "%m", TQString().sprintf( "%02d", month() ) );
+ result.tqreplace( "%e", TQString().sprintf( "%d", day() ) );
+ result.tqreplace( "%d", TQString().sprintf( "%02d", day() ) );
+ result.tqreplace( "%b", shortMonthName( month() ) );
+ result.tqreplace( "%B", longMonthName( month() ) );
+ result.tqreplace( "%a", shortDayName( dayOfWeek() ) );
+ result.tqreplace( "%A", longDayName( dayOfWeek() ) );
return result;
}
@@ -311,7 +311,7 @@ TQString ExtDate::toString( const TQString& format ) const
bool ExtDate::setYMD( int y, int m, int d )
{
if ( ! isValid(y,m,d) ) {
-#if defined(QT_CHECK_RANGE)
+#if defined(TQT_CHECK_RANGE)
qWarning( "ExtDate: Invalid date %04d-%02d-%02d", y, m, d );
#endif
m_year = 0;
@@ -377,7 +377,7 @@ int ExtDate::daysTo( const ExtDate & a_date) const
return a_date.jd() - jd();
}
-ExtDate ExtDate::currentDate(Qt::TimeSpec ts)
+ExtDate ExtDate::tqcurrentDate(Qt::TimeSpec ts)
{
time_t a_current_time;
struct tm a_current_time_tm;
@@ -385,11 +385,11 @@ ExtDate ExtDate::currentDate(Qt::TimeSpec ts)
time(&a_current_time);
switch (ts)
{
- case Qt::LocalTime :
+ case TQt::LocalTime :
localtime_r(&a_current_time, &a_current_time_tm);
break;
- case Qt::UTC :
+ case TQt::UTC :
gmtime_r(&a_current_time, &a_current_time_tm);
break;
@@ -400,7 +400,7 @@ ExtDate ExtDate::currentDate(Qt::TimeSpec ts)
return ExtDate(a_current_time_tm.tm_year + 1900, a_current_time_tm.tm_mon + 1, a_current_time_tm.tm_mday);
}
-#ifndef QT_NO_DATESTRING
+#ifndef TQT_NO_DATESTRING
//Try both DateFormat values
ExtDate ExtDate::fromString( const TQString& s )
{
@@ -417,7 +417,7 @@ ExtDate ExtDate::fromString( const TQString& s, Qt::DateFormat f )
ExtDate dt = ExtDate(); //initialize invalid date
if ( s.isEmpty() ) { return dt; }
if ( f == Qt::LocalDate ) { //can't use LocalFormat
-#if defined(QT_CHECK_RANGE)
+#if defined(TQT_CHECK_RANGE)
qWarning( "TQDate::fromString: Parameter out of range" );
#endif
return dt;
@@ -436,7 +436,7 @@ ExtDate ExtDate::fromString( const TQString& s, Qt::DateFormat f )
break;
default :
-#ifndef QT_NO_TEXTDATE
+#ifndef TQT_NO_TEXTDATE
case Qt::TextDate :
{
//Three possible date formats:
@@ -499,12 +499,12 @@ ExtDate ExtDate::fromString( const TQString& s, Qt::DateFormat f )
}
#else
break;
-#endif //ifndef QT_NO_TEXTDATE
+#endif //ifndef TQT_NO_TEXTDATE
}
return dt;
}
-#endif //ifndef QT_NO_DATESTRING
+#endif //ifndef TQT_NO_DATESTRING
bool ExtDate::isValid( int y, int m, int d )
{
@@ -559,7 +559,7 @@ int ExtDate::dayOfYear(int y, int m, int d)
A ExtDateTime object is typically created either by giving a date
and time explicitly in the constructor, or by using the static
- function currentDateTime(), which returns a ExtDateTime object set
+ function tqcurrentDateTime(), which returns a ExtDateTime object set
to the system clock's time. The date and time can be changed with
setDate() and setTime(). A datetime can also be set using the
setTime_t() function, which takes a POSIX-standard "number of
@@ -710,8 +710,8 @@ void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC )
}
/*!
- Sets the date and time to \a ts time (\c Qt::LocalTime or \c
- Qt::UTC) given the number of seconds that have passed since
+ Sets the date and time to \a ts time (\c TQt::LocalTime or \c
+ TQt::UTC) given the number of seconds that have passed since
1970-01-01T00:00:00, Coordinated Universal Time (UTC). On systems
that do not support timezones this function will behave as if
local time were UTC.
@@ -726,11 +726,11 @@ void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )
time_t tmp = (time_t) secsSince1Jan1970UTC;
tm *brokenDown = 0;
-#if defined(Q_OS_UNIX) && defined(QT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+#if defined(Q_OS_UNIX) && defined(TQT_THREAD_SUPPORT) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// posix compliant system
// use the reentrant versions of localtime() and gmtime() where available
tm res;
- if ( ts == Qt::LocalTime )
+ if ( ts == TQt::LocalTime )
brokenDown = localtime_r( &tmp, &res );
if ( !brokenDown ) {
brokenDown = gmtime_r( &tmp, &res );
@@ -742,7 +742,7 @@ void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )
}
}
#else
- if ( ts == Qt::LocalTime )
+ if ( ts == TQt::LocalTime )
brokenDown = localtime( &tmp );
if ( !brokenDown ) {
brokenDown = gmtime( &tmp );
@@ -763,8 +763,8 @@ void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )
// MSECS_PER_MIN * brokenDown->tm_min +
// 1000 * brokenDown->tm_sec;
}
-#ifndef QT_NO_DATESTRING
-#ifndef QT_NO_SPRINTF
+#ifndef TQT_NO_DATESTRING
+#ifndef TQT_NO_SPRINTF
/*!
\overload
@@ -792,12 +792,12 @@ void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )
TQString ExtDateTime::toString( Qt::DateFormat f ) const
{
if ( !isValid() )
- return TQString::null;
+ return TQString();
if ( f == Qt::ISODate ) {
return d.toString( Qt::ISODate ) + "T" + t.toString( Qt::ISODate );
}
-#ifndef QT_NO_TEXTDATE
+#ifndef TQT_NO_TEXTDATE
else if ( f == Qt::TextDate ) {
return toString( "%a %b %e %Y %H:%M:%S" );
}
@@ -807,14 +807,14 @@ TQString ExtDateTime::toString( Qt::DateFormat f ) const
+ " " + KGlobal::locale()->timeFormat() );
}
- return TQString::null;
+ return TQString();
}
#endif
TQString ExtDateTime::toString( const TQString& format ) const
{
if ( !isValid() )
- return TQString::null;
+ return TQString();
//Parse the date portion of the format string
TQString result = date().toString( format );
@@ -833,17 +833,17 @@ TQString ExtDateTime::toString( const TQString& format ) const
int h = time().hour();
- result.replace( "%H", TQString().sprintf( "%02d", h ) );
- result.replace( "%k", TQString().sprintf( "%d", h ) );
- result.replace( "%I", TQString().sprintf( "%02d", ( h > 12 ) ? h-12 : h ) );
- result.replace( "%l", TQString().sprintf( "%d", ( h > 12 ) ? h-12 : h ) );
- result.replace( "%M", TQString().sprintf( "%02d", time().minute() ) );
- result.replace( "%S", TQString().sprintf( "%02d", time().second() ) );
- result.replace( "%p", TQString().sprintf( "%s", ( h > 12 ) ? "pm" : "am" ) );
+ result.tqreplace( "%H", TQString().sprintf( "%02d", h ) );
+ result.tqreplace( "%k", TQString().sprintf( "%d", h ) );
+ result.tqreplace( "%I", TQString().sprintf( "%02d", ( h > 12 ) ? h-12 : h ) );
+ result.tqreplace( "%l", TQString().sprintf( "%d", ( h > 12 ) ? h-12 : h ) );
+ result.tqreplace( "%M", TQString().sprintf( "%02d", time().minute() ) );
+ result.tqreplace( "%S", TQString().sprintf( "%02d", time().second() ) );
+ result.tqreplace( "%p", TQString().sprintf( "%s", ( h > 12 ) ? "pm" : "am" ) );
return result;
}
-#endif //QT_NO_DATESTRING
+#endif //TQT_NO_DATESTRING
/*!
Returns a ExtDateTime object containing a datetime \a ndays days
@@ -933,7 +933,7 @@ int ExtDateTime::daysTo( const ExtDateTime &dt ) const
Example:
\code
- ExtDateTime dt = ExtDateTime::currentDateTime();
+ ExtDateTime dt = ExtDateTime::tqcurrentDateTime();
ExtDateTime xmas( ExtDate(dt.date().year(),12,24), TQTime(17,00) );
kdDebug( ) << "There are " << dt.secsTo(xmas) << " seconds to Christmas" << endl;
\endcode
@@ -1023,33 +1023,33 @@ bool ExtDateTime::operator>=( const ExtDateTime &dt ) const
Returns the current datetime, as reported by the system clock.
- \sa ExtDate::currentDate(), TQTime::currentTime()
+ \sa ExtDate::tqcurrentDate(), TQTime::currentTime()
*/
-ExtDateTime ExtDateTime::currentDateTime()
+ExtDateTime ExtDateTime::tqcurrentDateTime()
{
- return currentDateTime( Qt::LocalTime );
+ return tqcurrentDateTime( Qt::LocalTime );
}
/*!
Returns the current datetime, as reported by the system clock, for the
TimeSpec \a ts. The default TimeSpec is LocalTime.
- \sa ExtDate::currentDate(), TQTime::currentTime(), Qt::TimeSpec
+ \sa ExtDate::tqcurrentDate(), TQTime::currentTime(), Qt::TimeSpec
*/
-ExtDateTime ExtDateTime::currentDateTime( Qt::TimeSpec ts )
+ExtDateTime ExtDateTime::tqcurrentDateTime( Qt::TimeSpec ts )
{
ExtDateTime dt;
- dt.setDate( ExtDate::currentDate(ts) );
+ dt.setDate( ExtDate::tqcurrentDate(ts) );
TQTime t = t.currentTime(ts);
if ( t.hour()==0 && t.minute()==0 ) // midnight or right after?
- dt.setDate( ExtDate::currentDate(ts) ); // fetch date again
+ dt.setDate( ExtDate::tqcurrentDate(ts) ); // fetch date again
dt.setTime( t );
return dt;
}
-#ifndef QT_NO_DATESTRING
+#ifndef TQT_NO_DATESTRING
/*!
Returns the ExtDateTime represented by the string \a s, using the
format \a f, or an invalid datetime if this is not possible.
@@ -1076,7 +1076,7 @@ ExtDateTime ExtDateTime::fromString( const TQString& s, Qt::DateFormat f )
ExtDateTime dt;
if ( ( s.isEmpty() ) || ( f == Qt::LocalDate ) ) {
-#if defined(QT_CHECK_RANGE)
+#if defined(TQT_CHECK_RANGE)
qWarning( "ExtDateTime::fromString: Parameter out of range" );
#endif
dt.d.setJD( INVALID_DAY );
@@ -1084,7 +1084,7 @@ ExtDateTime ExtDateTime::fromString( const TQString& s, Qt::DateFormat f )
}
if ( f == Qt::ISODate ) {
- if ( s.length() <= 10 || ! s.contains( ':' ) ) { //no time specified
+ if ( s.length() <= 10 || ! s.tqcontains( ':' ) ) { //no time specified
TQTime t = TQTime(0,0,0);
return ExtDateTime( ExtDate::fromString( s.mid(0,10), Qt::ISODate ) );
} else {
@@ -1092,14 +1092,14 @@ ExtDateTime ExtDateTime::fromString( const TQString& s, Qt::DateFormat f )
TQTime::fromString( s.mid(11), Qt::ISODate ) );
}
}
-#if !defined(QT_NO_REGEXP) && !defined(QT_NO_TEXTDATE)
+#if !defined(TQT_NO_REGEXP) && !defined(TQT_NO_TEXTDATE)
else if ( f == Qt::TextDate ) {
//parse the time, if it exists.
TQTime time;
TQString sd = s;
int hour, minute, second;
- int pivot = s.find( TQRegExp(TQString::fromLatin1("[0-9][0-9]:[0-9][0-9]:[0-9][0-9]")) );
+ int pivot = s.tqfind( TQRegExp(TQString::tqfromLatin1("[0-9][0-9]:[0-9][0-9]:[0-9][0-9]")) );
if ( pivot != -1 ) {
hour = s.mid( pivot, 2 ).toInt();
minute = s.mid( pivot+3, 2 ).toInt();
@@ -1114,21 +1114,21 @@ ExtDateTime ExtDateTime::fromString( const TQString& s, Qt::DateFormat f )
return ExtDateTime( date, time );
}
-#endif //QT_NO_REGEXP
+#endif //TQT_NO_REGEXP
return ExtDateTime();
}
-#endif //QT_NO_DATESTRING
+#endif //TQT_NO_DATESTRING
-#ifndef QT_NO_DATASTREAM
+#ifndef TQT_NO_DATASTREAM
KDE_EXPORT TQDataStream &operator<<( TQDataStream & ostream, const ExtDate & date)
{
- return ostream << (Q_UINT32)(date.jd());
+ return ostream << (TQ_UINT32)(date.jd());
}
KDE_EXPORT TQDataStream &operator>>( TQDataStream & ostream, ExtDate & date)
{
- Q_UINT32 julday;
+ TQ_UINT32 julday;
ostream >> julday;
date.setJD( julday );
return ostream;
@@ -1136,7 +1136,9 @@ KDE_EXPORT TQDataStream &operator>>( TQDataStream & ostream, ExtDate & date)
KDE_EXPORT TQDataStream &operator<<( TQDataStream & ostream, const ExtDateTime & dt)
{
- return ostream << dt.d << dt.t;
+ ostream << dt.d;
+ ostream << dt.t;
+ return ostream;
}
KDE_EXPORT TQDataStream &operator>>( TQDataStream & ostream, ExtDateTime & dt)
@@ -1145,4 +1147,4 @@ KDE_EXPORT TQDataStream &operator>>( TQDataStream & ostream, ExtDateTime & dt)
return ostream;
}
-#endif // QT_NO_DATASTREAM
+#endif // TQT_NO_DATASTREAM