Skip to content

Commit

Permalink
Set completition date also when theres no creation date, closes gsant…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Feb 9, 2020
1 parent c2cf5a7 commit be626b1
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ public SttTaskWithParserInfo parseTask(final String line) {
task.setPriority(parsePriority(line));
task.setKeyValuePairs(parseKeyValuePairs(line));
task.setDueDate(parseDueDate(line));

System.out.print("");
return task;
}

Expand Down Expand Up @@ -164,7 +162,11 @@ private char parsePriority(String line) {
}

private String parseDescription(String line) {
return parseOneValueOrDefault(line, PATTERN_DESCRIPTION, "");
String d = parseOneValueOrDefault(line, PATTERN_DESCRIPTION, "");
if (parseCreationDate(line).isEmpty() && d.startsWith(" " + parseCompletionDate(line) + " ")) {
d = d.substring(1 + 4 + 1 + 2 + 1 + 2 + 1);
}
return d;
}

private Map<String, String> parseKeyValuePairs(String line) {
Expand Down Expand Up @@ -222,12 +224,12 @@ public SttCommander regenerateTaskLine(SttTaskWithParserInfo task) {
String tmp;
if (task.isDone()) {
sb.append("x ");
if (!nz(task.getCompletionDate())) {
task.setCompletionDate(getToday());
}
sb.append(task.getCompletionDate());
sb.append(" ");
if (nz(tmp = task.getCreationDate())) {
if (!nz(task.getCompletionDate())) {
task.setCompletionDate(getToday());
}
sb.append(task.getCompletionDate());
sb.append(" ");
sb.append(tmp);
sb.append(" ");
}
Expand Down

0 comments on commit be626b1

Please sign in to comment.