euroJackpot(args);
} else if (QString("lotto").startsWith(arg0)){
lotto(args);
+ } else if (QString("nofm").startsWith(arg0)){
+ nOfM(args);
} else if (QString("time").startsWith(arg0)){
time(args);
} else {
if (count > 0){
QString line;
for (uint ix = 0; ix < count; ix++){
- line = QString::number(ix + 1) + ": " + calcNOfM(5, 50)
+ line = QString::number(ix + 1) + ": " + calcNOfM(6, 49)
+ " | " + calcNOfM(1, 10);
out(line);
}
}
}
+/**
+ * Displays proposals for the Euro Jackpot.
+ *
+ * @param args the command arguments
+ */
+void CommandProcessor::nOfM(const QStringList& args){
+ uint n, m;
+ if (args.count() < 3){
+ help("too few parameter: <n> <m> expected", args);
+ } else {
+ QString arg1 = args.at(1);
+ QString arg2 = args.at(2);
+ if (ReQStringUtils::lengthOfUInt(arg1, 0, 10, &n) != arg1.length()){
+ help("not a number: <n>", args);
+ } else if (ReQStringUtils::lengthOfUInt(arg2, 0, 10, &m) != arg2.length()){
+ help("not a number: <n>", args);
+ } else if (n < 2){
+ help(" <n> < 2", args);
+ } else if (m < 2){
+ help(" <n> < <m>", args);
+ } else {
+ out(calcNOfM(n, m));
+ }
+ }
+}
/**
* Displays a time expression
* @param args the command arguments
*/
void CommandProcessor::time(const QStringList& args){
+ if (args.count() != 2){
+ help("not one argument <time>", args);
+ } else {
+ QString arg1 = args.at(1);
+ uint time;
+ QDateTime date;
+ if (ReQStringUtils::lengthOfUInt(arg1, 0, 10, &time) == arg1.length()){
+ date = QDateTime::fromMSecsSinceEpoch(time * 1000LL);
+ out(date.toString("yyyy.MM.dd hh:mm:ss"));
+ } else if (ReQStringUtils::lengthOfDateTime(arg1, 0, false, false, &date) == arg1.length()){
+ out(QString::number(date.toMSecsSinceEpoch() / 1000L));
+ } else {
+ help("unknown date/time format", args);
+ }
+ }
}