]> Git trees. - libqmvoc.git/commitdiff
Some obscure fixes related to setting the clock on startup:
authorJason Harris <kstars@30doradus.org>
Wed, 2 Nov 2005 06:24:02 +0000 (06:24 +0000)
committerJason Harris <kstars@30doradus.org>
Wed, 2 Nov 2005 06:24:02 +0000 (06:24 +0000)
+ 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
extdate/extdatetime.h

index 4364945f863139c5a5ba013e77d7a9cb2a92e25b..7cd96512b9bec834dad839d9080f2ac61d6c3674 100644 (file)
@@ -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;
index a82ebb8211f400e55a0d641ce6236dc3ef34e132..e117cbbe206f84de2573367d7f18b8c013a62beb 100644 (file)
@@ -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: