Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#### Review fixes

- Accepted an explicit leading `+` in time estimates and other duration expressions, alongside existing negative durations.
- Preserved balanced closing parentheses, brackets, and braces in relative file-link filenames while excluding surrounding punctuation.
- Preserved unsaved archive buffers, serialized simultaneous transfers, and replaced closed archive files only after a complete write. Failed writes, stale source documents, and rejected editor edits keep source tasks intact.
- Preserved archive task order, sibling project structure, attached comment indentation, and standalone notes when removing empty projects.
Expand Down
6 changes: 3 additions & 3 deletions src/utils/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ const Time = {
normalizedDaysPerWeek = Math.max(1, Number(manDaysPerWeek) || 5);

if (
/^\s*-\s*\d/.test(to) &&
/^\s*[+-]\s*\d/.test(to) &&
/\d+(?:\.\d+)?\s*(?:m[dw]|ms|[smhdwy]|seconds?|minutes?|hours?|days?|weeks?|years?)(?=\d|\W|$)/i.test(
to
)
) {
durationSign = -1;
to = to.replace(/^\s*-\s*/, '');
durationSign = /^\s*-/.test(to) ? -1 : 1;
to = to.replace(/^\s*[+-]\s*/, '');
}

to = to.replace(/(\d+(?:\.\d+)?)\s*mw(?=\d|\W|$)/gi, (match, weeks) => {
Expand Down
8 changes: 8 additions & 0 deletions test/time.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ describe('Time utilities', () => {
expect(Time.diff(formatted, from, 'man-weeks', 24, 6, 3)).to.equal(formatted);
});

it('accepts an explicit positive sign on duration expressions', () => {
const from = new Date('2020-01-01T00:00:00Z');

expect(Time.durationSeconds('+1h 30m', from)).to.equal(90 * 60);
expect(Time.diffSeconds(' + 2md 1h', from, 8, 5)).to.equal(17 * 3600);
expect(Time.diff('+1h 30m', from, 'short')).to.equal('1h 30m');
});

it('applies a leading sign to complete man-time durations', () => {
const from = new Date('2020-01-01T00:00:00Z'),
negativeManDay = Time.diff(
Expand Down
Loading