|
|
@ -241,7 +241,7 @@ TQString ExtDate::longDayName( int weekday ) {return m_longDayNames[weekday-1];}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef TQT_NO_TEXTSTRING
|
|
|
|
#ifndef TQT_NO_TEXTSTRING
|
|
|
|
#if !defined(TQT_NO_SPRINTF)
|
|
|
|
#if !defined(TQT_NO_SPRINTF)
|
|
|
|
TQString ExtDate::toString( Qt::DateFormat f) const
|
|
|
|
TQString ExtDate::toString( TQt::DateFormat f) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQString a_format;
|
|
|
|
TQString a_format;
|
|
|
|
|
|
|
|
|
|
|
@ -249,15 +249,15 @@ TQString ExtDate::toString( Qt::DateFormat f) const
|
|
|
|
|
|
|
|
|
|
|
|
switch (f)
|
|
|
|
switch (f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case Qt::TextDate : // Sat May 20 1995
|
|
|
|
case TQt::TextDate : // Sat May 20 1995
|
|
|
|
a_format = "%a %b %e %Y";
|
|
|
|
a_format = "%a %b %e %Y";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Qt::ISODate : // YYYY-MM-DD
|
|
|
|
case TQt::ISODate : // YYYY-MM-DD
|
|
|
|
a_format = "%Y-%m-%d";
|
|
|
|
a_format = "%Y-%m-%d";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case Qt::LocalDate : // local settings
|
|
|
|
case TQt::LocalDate : // local settings
|
|
|
|
a_format = TDEGlobal::locale()->dateFormat();
|
|
|
|
a_format = TDEGlobal::locale()->dateFormat();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -377,7 +377,7 @@ int ExtDate::daysTo( const ExtDate & a_date) const
|
|
|
|
return a_date.jd() - jd();
|
|
|
|
return a_date.jd() - jd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExtDate ExtDate::currentDate(Qt::TimeSpec ts)
|
|
|
|
ExtDate ExtDate::currentDate(TQt::TimeSpec ts)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
time_t a_current_time;
|
|
|
|
time_t a_current_time;
|
|
|
|
struct tm a_current_time_tm;
|
|
|
|
struct tm a_current_time_tm;
|
|
|
@ -404,19 +404,19 @@ ExtDate ExtDate::currentDate(Qt::TimeSpec ts)
|
|
|
|
//Try both DateFormat values
|
|
|
|
//Try both DateFormat values
|
|
|
|
ExtDate ExtDate::fromString( const TQString& s )
|
|
|
|
ExtDate ExtDate::fromString( const TQString& s )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ExtDate dResult = ExtDate::fromString( s, Qt::TextDate );
|
|
|
|
ExtDate dResult = ExtDate::fromString( s, TQt::TextDate );
|
|
|
|
if ( dResult.isValid() ) return dResult;
|
|
|
|
if ( dResult.isValid() ) return dResult;
|
|
|
|
|
|
|
|
|
|
|
|
dResult = ExtDate::fromString( s, Qt::ISODate );
|
|
|
|
dResult = ExtDate::fromString( s, TQt::ISODate );
|
|
|
|
if ( dResult.isValid() ) return dResult;
|
|
|
|
if ( dResult.isValid() ) return dResult;
|
|
|
|
else return ExtDate(); //invalid
|
|
|
|
else return ExtDate(); //invalid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExtDate ExtDate::fromString( const TQString& s, Qt::DateFormat f )
|
|
|
|
ExtDate ExtDate::fromString( const TQString& s, TQt::DateFormat f )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ExtDate dt = ExtDate(); //initialize invalid date
|
|
|
|
ExtDate dt = ExtDate(); //initialize invalid date
|
|
|
|
if ( s.isEmpty() ) { return dt; }
|
|
|
|
if ( s.isEmpty() ) { return dt; }
|
|
|
|
if ( f == Qt::LocalDate ) { //can't use LocalFormat
|
|
|
|
if ( f == TQt::LocalDate ) { //can't use LocalFormat
|
|
|
|
#if defined(TQT_CHECK_RANGE)
|
|
|
|
#if defined(TQT_CHECK_RANGE)
|
|
|
|
tqWarning( "TQDate::fromString: Parameter out of range" );
|
|
|
|
tqWarning( "TQDate::fromString: Parameter out of range" );
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -424,7 +424,7 @@ ExtDate ExtDate::fromString( const TQString& s, Qt::DateFormat f )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch( f ) {
|
|
|
|
switch( f ) {
|
|
|
|
case Qt::ISODate :
|
|
|
|
case TQt::ISODate :
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int year( s.mid( 0, 4 ).toInt() );
|
|
|
|
int year( s.mid( 0, 4 ).toInt() );
|
|
|
|
int month( s.mid( 5, 2 ).toInt() );
|
|
|
|
int month( s.mid( 5, 2 ).toInt() );
|
|
|
@ -437,7 +437,7 @@ ExtDate ExtDate::fromString( const TQString& s, Qt::DateFormat f )
|
|
|
|
|
|
|
|
|
|
|
|
default :
|
|
|
|
default :
|
|
|
|
#ifndef TQT_NO_TEXTDATE
|
|
|
|
#ifndef TQT_NO_TEXTDATE
|
|
|
|
case Qt::TextDate :
|
|
|
|
case TQt::TextDate :
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Three possible date formats:
|
|
|
|
//Three possible date formats:
|
|
|
|
//dd mth yyyy; mth dd yyyy; wkd mth dd yyyy
|
|
|
|
//dd mth yyyy; mth dd yyyy; wkd mth dd yyyy
|
|
|
@ -706,7 +706,7 @@ uint ExtDateTime::toTime_t() const
|
|
|
|
|
|
|
|
|
|
|
|
void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC )
|
|
|
|
void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setTime_t( secsSince1Jan1970UTC, Qt::LocalTime );
|
|
|
|
setTime_t( secsSince1Jan1970UTC, TQt::LocalTime );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
@ -721,7 +721,7 @@ void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC )
|
|
|
|
|
|
|
|
|
|
|
|
\sa toTime_t()
|
|
|
|
\sa toTime_t()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )
|
|
|
|
void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC, TQt::TimeSpec ts )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
time_t tmp = (time_t) secsSince1Jan1970UTC;
|
|
|
|
time_t tmp = (time_t) secsSince1Jan1970UTC;
|
|
|
|
tm *brokenDown = 0;
|
|
|
|
tm *brokenDown = 0;
|
|
|
@ -771,16 +771,16 @@ void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )
|
|
|
|
Returns the datetime as a string. The \a f parameter determines
|
|
|
|
Returns the datetime as a string. The \a f parameter determines
|
|
|
|
the format of the string.
|
|
|
|
the format of the string.
|
|
|
|
|
|
|
|
|
|
|
|
If \a f is \c Qt::TextDate, the string format is "Wed May 20
|
|
|
|
If \a f is \c TQt::TextDate, the string format is "Wed May 20
|
|
|
|
03:40:13 1998" (using ExtDate::shortDayName(), ExtDate::shortMonthName(),
|
|
|
|
03:40:13 1998" (using ExtDate::shortDayName(), ExtDate::shortMonthName(),
|
|
|
|
and TQTime::toString() to generate the string, so the day and month
|
|
|
|
and TQTime::toString() to generate the string, so the day and month
|
|
|
|
names will have localized names).
|
|
|
|
names will have localized names).
|
|
|
|
|
|
|
|
|
|
|
|
If \a f is \c Qt::ISODate, the string format corresponds to the
|
|
|
|
If \a f is \c TQt::ISODate, the string format corresponds to the
|
|
|
|
ISO 8601 extended specification for representations of dates and
|
|
|
|
ISO 8601 extended specification for representations of dates and
|
|
|
|
times, which is YYYY-MM-DDTHH:MM:SS.
|
|
|
|
times, which is YYYY-MM-DDTHH:MM:SS.
|
|
|
|
|
|
|
|
|
|
|
|
If \a f is \c Qt::LocalDate, the string format depends on the
|
|
|
|
If \a f is \c TQt::LocalDate, the string format depends on the
|
|
|
|
locale settings of the system.
|
|
|
|
locale settings of the system.
|
|
|
|
|
|
|
|
|
|
|
|
If the format \a f is invalid or the datetime is invalid, toString()
|
|
|
|
If the format \a f is invalid or the datetime is invalid, toString()
|
|
|
@ -789,20 +789,20 @@ void ExtDateTime::setTime_t( uint secsSince1Jan1970UTC, Qt::TimeSpec ts )
|
|
|
|
\sa ExtDate::toString() TQTime::toString()
|
|
|
|
\sa ExtDate::toString() TQTime::toString()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
TQString ExtDateTime::toString( Qt::DateFormat f ) const
|
|
|
|
TQString ExtDateTime::toString( TQt::DateFormat f ) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( !isValid() )
|
|
|
|
if ( !isValid() )
|
|
|
|
return TQString();
|
|
|
|
return TQString();
|
|
|
|
|
|
|
|
|
|
|
|
if ( f == Qt::ISODate ) {
|
|
|
|
if ( f == TQt::ISODate ) {
|
|
|
|
return d.toString( Qt::ISODate ) + "T" + t.toString( Qt::ISODate );
|
|
|
|
return d.toString( TQt::ISODate ) + "T" + t.toString( TQt::ISODate );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifndef TQT_NO_TEXTDATE
|
|
|
|
#ifndef TQT_NO_TEXTDATE
|
|
|
|
else if ( f == Qt::TextDate ) {
|
|
|
|
else if ( f == TQt::TextDate ) {
|
|
|
|
return toString( "%a %b %e %Y %H:%M:%S" );
|
|
|
|
return toString( "%a %b %e %Y %H:%M:%S" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
else if ( f == Qt::LocalDate ) {
|
|
|
|
else if ( f == TQt::LocalDate ) {
|
|
|
|
return toString( TDEGlobal::locale()->dateFormat()
|
|
|
|
return toString( TDEGlobal::locale()->dateFormat()
|
|
|
|
+ " " + TDEGlobal::locale()->timeFormat() );
|
|
|
|
+ " " + TDEGlobal::locale()->timeFormat() );
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1028,17 +1028,17 @@ bool ExtDateTime::operator>=( const ExtDateTime &dt ) const
|
|
|
|
|
|
|
|
|
|
|
|
ExtDateTime ExtDateTime::currentDateTime()
|
|
|
|
ExtDateTime ExtDateTime::currentDateTime()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return currentDateTime( Qt::LocalTime );
|
|
|
|
return currentDateTime( TQt::LocalTime );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
Returns the current datetime, as reported by the system clock, for the
|
|
|
|
Returns the current datetime, as reported by the system clock, for the
|
|
|
|
TimeSpec \a ts. The default TimeSpec is LocalTime.
|
|
|
|
TimeSpec \a ts. The default TimeSpec is LocalTime.
|
|
|
|
|
|
|
|
|
|
|
|
\sa ExtDate::currentDate(), TQTime::currentTime(), Qt::TimeSpec
|
|
|
|
\sa ExtDate::currentDate(), TQTime::currentTime(), TQt::TimeSpec
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
ExtDateTime ExtDateTime::currentDateTime( Qt::TimeSpec ts )
|
|
|
|
ExtDateTime ExtDateTime::currentDateTime( TQt::TimeSpec ts )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ExtDateTime dt;
|
|
|
|
ExtDateTime dt;
|
|
|
|
dt.setDate( ExtDate::currentDate(ts) );
|
|
|
|
dt.setDate( ExtDate::currentDate(ts) );
|
|
|
@ -1054,28 +1054,28 @@ ExtDateTime ExtDateTime::currentDateTime( Qt::TimeSpec ts )
|
|
|
|
Returns the ExtDateTime represented by the string \a s, using the
|
|
|
|
Returns the ExtDateTime represented by the string \a s, using the
|
|
|
|
format \a f, or an invalid datetime if this is not possible.
|
|
|
|
format \a f, or an invalid datetime if this is not possible.
|
|
|
|
|
|
|
|
|
|
|
|
Note for \c Qt::TextDate: It is recommended that you use the
|
|
|
|
Note for \c TQt::TextDate: It is recommended that you use the
|
|
|
|
English short month names (e.g. "Jan"). Although localized month
|
|
|
|
English short month names (e.g. "Jan"). Although localized month
|
|
|
|
names can also be used, they depend on the user's locale settings.
|
|
|
|
names can also be used, they depend on the user's locale settings.
|
|
|
|
|
|
|
|
|
|
|
|
\warning Note that \c Qt::LocalDate cannot be used here.
|
|
|
|
\warning Note that \c TQt::LocalDate cannot be used here.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
ExtDateTime ExtDateTime::fromString( const TQString& s )
|
|
|
|
ExtDateTime ExtDateTime::fromString( const TQString& s )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ExtDateTime dtResult = ExtDateTime::fromString( s, Qt::TextDate );
|
|
|
|
ExtDateTime dtResult = ExtDateTime::fromString( s, TQt::TextDate );
|
|
|
|
if ( dtResult.isValid() ) return dtResult;
|
|
|
|
if ( dtResult.isValid() ) return dtResult;
|
|
|
|
|
|
|
|
|
|
|
|
dtResult = ExtDateTime::fromString( s, Qt::ISODate );
|
|
|
|
dtResult = ExtDateTime::fromString( s, TQt::ISODate );
|
|
|
|
|
|
|
|
|
|
|
|
if ( dtResult.isValid() ) return dtResult;
|
|
|
|
if ( dtResult.isValid() ) return dtResult;
|
|
|
|
else return ExtDateTime(); //invalid
|
|
|
|
else return ExtDateTime(); //invalid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ExtDateTime ExtDateTime::fromString( const TQString& s, Qt::DateFormat f )
|
|
|
|
ExtDateTime ExtDateTime::fromString( const TQString& s, TQt::DateFormat f )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ExtDateTime dt;
|
|
|
|
ExtDateTime dt;
|
|
|
|
|
|
|
|
|
|
|
|
if ( ( s.isEmpty() ) || ( f == Qt::LocalDate ) ) {
|
|
|
|
if ( ( s.isEmpty() ) || ( f == TQt::LocalDate ) ) {
|
|
|
|
#if defined(TQT_CHECK_RANGE)
|
|
|
|
#if defined(TQT_CHECK_RANGE)
|
|
|
|
tqWarning( "ExtDateTime::fromString: Parameter out of range" );
|
|
|
|
tqWarning( "ExtDateTime::fromString: Parameter out of range" );
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -1083,17 +1083,17 @@ ExtDateTime ExtDateTime::fromString( const TQString& s, Qt::DateFormat f )
|
|
|
|
return dt;
|
|
|
|
return dt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( f == Qt::ISODate ) {
|
|
|
|
if ( f == TQt::ISODate ) {
|
|
|
|
if ( s.length() <= 10 || ! s.contains( ':' ) ) { //no time specified
|
|
|
|
if ( s.length() <= 10 || ! s.contains( ':' ) ) { //no time specified
|
|
|
|
TQTime t = TQTime(0,0,0);
|
|
|
|
TQTime t = TQTime(0,0,0);
|
|
|
|
return ExtDateTime( ExtDate::fromString( s.mid(0,10), Qt::ISODate ) );
|
|
|
|
return ExtDateTime( ExtDate::fromString( s.mid(0,10), TQt::ISODate ) );
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return ExtDateTime( ExtDate::fromString( s.mid(0,10), Qt::ISODate ),
|
|
|
|
return ExtDateTime( ExtDate::fromString( s.mid(0,10), TQt::ISODate ),
|
|
|
|
TQTime::fromString( s.mid(11), Qt::ISODate ) );
|
|
|
|
TQTime::fromString( s.mid(11), TQt::ISODate ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if !defined(TQT_NO_REGEXP) && !defined(TQT_NO_TEXTDATE)
|
|
|
|
#if !defined(TQT_NO_REGEXP) && !defined(TQT_NO_TEXTDATE)
|
|
|
|
else if ( f == Qt::TextDate ) {
|
|
|
|
else if ( f == TQt::TextDate ) {
|
|
|
|
|
|
|
|
|
|
|
|
//parse the time, if it exists.
|
|
|
|
//parse the time, if it exists.
|
|
|
|
TQTime time;
|
|
|
|
TQTime time;
|
|
|
@ -1110,7 +1110,7 @@ ExtDateTime ExtDateTime::fromString( const TQString& s, Qt::DateFormat f )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//sd is now just the date string.
|
|
|
|
//sd is now just the date string.
|
|
|
|
ExtDate date = ExtDate::fromString( s, Qt::TextDate );
|
|
|
|
ExtDate date = ExtDate::fromString( s, TQt::TextDate );
|
|
|
|
return ExtDateTime( date, time );
|
|
|
|
return ExtDateTime( date, time );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|