@@ -377,31 +377,16 @@ static int checkOKShutdown(bool bWantRecStatus)
377
377
return res;
378
378
}
379
379
380
- static int setWakeupTime (QString sWakeupTime )
380
+ static void setWakeupTime (const QDateTime &wakeupTime )
381
381
{
382
382
LOG (VB_GENERAL, LOG_INFO, " Mythshutdown: --setwakeup" );
383
383
384
384
LOG (VB_GENERAL, LOG_NOTICE,
385
- QString (" Mythshutdown: wakeup time given is: %1" ).arg (sWakeupTime ));
386
-
387
- // check time given is valid
388
- QDateTime dtWakeupTime;
389
- dtWakeupTime = MythDate::fromString (sWakeupTime );
390
-
391
- if (!dtWakeupTime.isValid ())
392
- {
393
- LOG (VB_GENERAL, LOG_ERR,
394
- QString (" Mythshutdown: --setwakeup invalid date "
395
- " format (%1)\n\t\t\t "
396
- " must be yyyy-MM-ddThh:mm:ss" )
397
- .arg (sWakeupTime ));
398
- return 1 ;
399
- }
385
+ QString (" Mythshutdown: wakeup time given is: %1 (local time)" )
386
+ .arg (MythDate::toString (wakeupTime)));
400
387
401
388
setGlobalSetting (" MythShutdownNextScheduled" ,
402
- MythDate::toString (dtWakeupTime, MythDate::kDatabase ));
403
-
404
- return 0 ;
389
+ MythDate::toString (wakeupTime, MythDate::kDatabase ));
405
390
}
406
391
407
392
static int setScheduledWakeupTime ()
@@ -434,7 +419,7 @@ static int setScheduledWakeupTime()
434
419
if (add)
435
420
restarttime = restarttime.addSecs ((-1 ) * add);
436
421
437
- setWakeupTime (restarttime. toString (Qt::ISODate) );
422
+ setWakeupTime (restarttime);
438
423
439
424
return 0 ;
440
425
}
@@ -823,7 +808,30 @@ int main(int argc, char **argv)
823
808
else if (cmdline.toBool (" status" ))
824
809
res = getStatus ((bool )(cmdline.toInt (" status" ) == 1 ));
825
810
else if (cmdline.toBool (" setwakeup" ))
826
- res = setWakeupTime (cmdline.toString (" setwakeup" ));
811
+ {
812
+ // only one of --utc or --localtime can be passed per
813
+ // CommandLineArg::AllowOneOf() in commandlineparser.cpp
814
+ bool utc = cmdline.toBool (" utc" );
815
+ QString tmp = cmdline.toString (" setwakeup" );
816
+
817
+ QDateTime wakeuptime = (utc) ?
818
+ MythDate::fromString (tmp) :
819
+ QDateTime::fromString (tmp, Qt::ISODate).toUTC ();
820
+
821
+ if (!wakeuptime.isValid ())
822
+ {
823
+ cerr << qPrintable (
824
+ QObject::tr (" mythshutdown: --setwakeup invalid date "
825
+ " format (%1)\n\t\t\t "
826
+ " must be yyyy-MM-ddThh:mm:ss" )
827
+ .arg (tmp)) << endl;
828
+ res = 1 ;
829
+ }
830
+ else
831
+ {
832
+ setWakeupTime (wakeuptime);
833
+ }
834
+ }
827
835
else if (cmdline.toBool (" safeshutdown" ))
828
836
{
829
837
res = checkOKShutdown (true );
0 commit comments