summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Thor Kristjansson <danielk@cuymedia.net>2012-11-21 15:27:31 (GMT)
committer Daniel Thor Kristjansson <danielk@cuymedia.net>2012-11-21 17:47:42 (GMT)
commitef7810c473e36d1022b62b1b411abf8efd49aa68 (patch)
tree46a353cf0d22ed23f6e56918234484adf275ea57
parent35ff26d382455af863ceaf4b1d05ff614f5c4fab (diff)
Fix #10995. Default to local time for mythshutdown --setwakeup.
-rw-r--r--mythtv/programs/mythshutdown/commandlineparser.cpp14
-rw-r--r--mythtv/programs/mythshutdown/main.cpp50
2 files changed, 42 insertions, 22 deletions
diff --git a/mythtv/programs/mythshutdown/commandlineparser.cpp b/mythtv/programs/mythshutdown/commandlineparser.cpp
index d1cb383..e30d38e 100644
--- a/mythtv/programs/mythshutdown/commandlineparser.cpp
+++ b/mythtv/programs/mythshutdown/commandlineparser.cpp
@@ -22,7 +22,8 @@ void MythShutdownCommandLineParser::LoadArguments(void)
CommandLineArg::AllowOneOf( QList<CommandLineArg*>()
<< add(QStringList( QStringList() << "-w" << "--setwakeup" ),
"setwakeup", "",
- "Set the wakeup time (yyyy-MM-ddThh:mm:ss)", "")
+ "Set the wakeup time (yyyy-MM-ddThh:mm:ss) "
+ "default is in local time", "")
<< add(QStringList( QStringList() << "-t" << "--setscheduledwakeup" ),
"setschedwakeup", false,
"Set wakeup time to the next scheduled recording", "")
@@ -66,5 +67,16 @@ void MythShutdownCommandLineParser::LoadArguments(void)
" 64 - In daily wakeup/shutdown period\n"
" 128 - Less than 15 minutes to next wakeup period\n"
" 255 - Setup is running") );
+
+ // The localtime command line parameter exists solely to make scripts
+ // using this executable self documenting.
+
+ CommandLineArg::AllowOneOf( QList<CommandLineArg*>()
+ << add("--utc",
+ "utc", false,
+ "Specify that the wakeup time is in utc", "")
+ << add("--localtime",
+ "localtime", false,
+ "Specify that the wakeup time is in local time", "") );
}
diff --git a/mythtv/programs/mythshutdown/main.cpp b/mythtv/programs/mythshutdown/main.cpp
index 8dd4f2e..db215ef 100644
--- a/mythtv/programs/mythshutdown/main.cpp
+++ b/mythtv/programs/mythshutdown/main.cpp
@@ -377,31 +377,16 @@ static int checkOKShutdown(bool bWantRecStatus)
return res;
}
-static int setWakeupTime(QString sWakeupTime)
+static void setWakeupTime(const QDateTime &wakeupTime)
{
LOG(VB_GENERAL, LOG_INFO, "Mythshutdown: --setwakeup");
LOG(VB_GENERAL, LOG_NOTICE,
- QString("Mythshutdown: wakeup time given is: %1").arg(sWakeupTime));
-
- // check time given is valid
- QDateTime dtWakeupTime;
- dtWakeupTime = MythDate::fromString(sWakeupTime);
-
- if (!dtWakeupTime.isValid())
- {
- LOG(VB_GENERAL, LOG_ERR,
- QString("Mythshutdown: --setwakeup invalid date "
- "format (%1)\n\t\t\t"
- "must be yyyy-MM-ddThh:mm:ss")
- .arg(sWakeupTime));
- return 1;
- }
+ QString("Mythshutdown: wakeup time given is: %1 (local time)")
+ .arg(MythDate::toString(wakeupTime)));
setGlobalSetting("MythShutdownNextScheduled",
- MythDate::toString(dtWakeupTime, MythDate::kDatabase));
-
- return 0;
+ MythDate::toString(wakeupTime, MythDate::kDatabase));
}
static int setScheduledWakeupTime()
@@ -434,7 +419,7 @@ static int setScheduledWakeupTime()
if (add)
restarttime = restarttime.addSecs((-1) * add);
- setWakeupTime(restarttime.toString(Qt::ISODate));
+ setWakeupTime(restarttime);
return 0;
}
@@ -823,7 +808,30 @@ int main(int argc, char **argv)
else if (cmdline.toBool("status"))
res = getStatus((bool)(cmdline.toInt("status") == 1));
else if (cmdline.toBool("setwakeup"))
- res = setWakeupTime(cmdline.toString("setwakeup"));
+ {
+ // only one of --utc or --localtime can be passed per
+ // CommandLineArg::AllowOneOf() in commandlineparser.cpp
+ bool utc = cmdline.toBool("utc");
+ QString tmp = cmdline.toString("setwakeup");
+
+ QDateTime wakeuptime = (utc) ?
+ MythDate::fromString(tmp) :
+ QDateTime::fromString(tmp, Qt::ISODate).toUTC();
+
+ if (!wakeuptime.isValid())
+ {
+ cerr << qPrintable(
+ QObject::tr("mythshutdown: --setwakeup invalid date "
+ "format (%1)\n\t\t\t"
+ "must be yyyy-MM-ddThh:mm:ss")
+ .arg(tmp)) << endl;
+ res = 1;
+ }
+ else
+ {
+ setWakeupTime(wakeuptime);
+ }
+ }
else if (cmdline.toBool("safeshutdown"))
{
res = checkOKShutdown(true);