From 80fc9013cba758e3eec96c6738bcfdbcc7f60752 Mon Sep 17 00:00:00 2001 From: Jason Harris Date: Wed, 2 Nov 2005 06:24:02 +0000 Subject: [PATCH] Some obscure fixes related to setting the clock on startup: + Make the ExtDate::fromString() function les picky about what date formats it accepts. + When setting the date from a script which is run from the command line, make sure to set the given time as the local time, not the UT. + Make sure focus position specified in a script is persistent if the script is run from the command line. (fwd-ported from branches/3.5) Thanks to Yannick Gingras for the bug report! svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=476799 --- extdate/extdatetime.cpp | 22 ++++++++++++++++++++++ extdate/extdatetime.h | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/extdate/extdatetime.cpp b/extdate/extdatetime.cpp index 4364945..7cd9651 100644 --- a/extdate/extdatetime.cpp +++ b/extdate/extdatetime.cpp @@ -431,6 +431,17 @@ ExtDate ExtDate::fromString( const QString &sDate, const QString &format ) { } } +ExtDate ExtDate::fromString( const QString& s ) +{ + ExtDate dResult = ExtDate::fromString( s, Qt::TextDate ); + if ( dResult.isValid() ) return dResult; + + dResult = ExtDate::fromString( s, Qt::ISODate ); + if ( dResult.isValid() ) return dResult; + else return ExtDate(); //invalid + +} + ExtDate ExtDate::fromString( const QString& s, Qt::DateFormat f ) { ExtDate dt = ExtDate(); //initialize invalid date @@ -1077,6 +1088,17 @@ ExtDateTime ExtDateTime::currentDateTime( Qt::TimeSpec ts ) \warning Note that \c Qt::LocalDate cannot be used here. */ +ExtDateTime ExtDateTime::fromString( const QString& s ) +{ + ExtDateTime dtResult = ExtDateTime::fromString( s, Qt::TextDate ); + if ( dtResult.isValid() ) return dtResult; + + dtResult = ExtDateTime::fromString( s, Qt::ISODate ); + + if ( dtResult.isValid() ) return dtResult; + else return ExtDateTime(); //invalid +} + ExtDateTime ExtDateTime::fromString( const QString& s, Qt::DateFormat f ) { ExtDateTime dt; diff --git a/extdate/extdatetime.h b/extdate/extdatetime.h index a82ebb8..e117cbb 100644 --- a/extdate/extdatetime.h +++ b/extdate/extdatetime.h @@ -90,7 +90,8 @@ public: static ExtDate currentDate( Qt::TimeSpec ts = Qt::LocalTime ); #ifndef QT_NO_DATESTRING - static ExtDate fromString( const QString& s, Qt::DateFormat f = Qt::TextDate ); + static ExtDate fromString( const QString& s ); + static ExtDate fromString( const QString& s, Qt::DateFormat ); static ExtDate fromString( const QString& s, const QString &format ); #endif static bool isValid( int y, int m, int d ); @@ -165,6 +166,7 @@ public: static ExtDateTime currentDateTime(); static ExtDateTime currentDateTime( Qt::TimeSpec ); #ifndef QT_NO_DATESTRING + static ExtDateTime fromString( const QString& s ); static ExtDateTime fromString( const QString& s, Qt::DateFormat f = Qt::TextDate ); #endif private: -- 2.47.3