Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 47f68ea

Browse files
Use spent at date if available, noref
1 parent 088acaa commit 47f68ea

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/models/hasTimes.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const Time = require('./time');
77
const regex = /added (.*) of time spent/i;
88
const subRegex = /subtracted (.*) of time spent/i;
99
const removeRegex = /Removed time spent/i;
10+
const dateRegex = /spent at (.*)/i;
1011

1112
/**
1213
* base model for models that have times
@@ -68,8 +69,9 @@ class hasTimes extends Base {
6869
});
6970

7071
let promise = this.parallel(this.notes, (note, done) => {
71-
let created = moment(note.created_at), match, subMatch;
72-
72+
let dateMatch = dateRegex.exec(note.body);
73+
let created = moment(dateMatch ? dateMatch[1] : note.created_at);
74+
let match, subMatch;
7375

7476
if ( //
7577
// filter out user notes
@@ -80,6 +82,7 @@ class hasTimes extends Base {
8082

8183
// create a time string and a time object
8284
let timeString = match ? match[1] : (subMatch ? `-${subMatch[1]}` : `-${Time.toHumanReadable(timeSpent, this.config.get('hoursPerDay'))}`);
85+
if (dateMatch) note.created_at = dateMatch[1];
8386
let time = new Time(timeString, note, this, this.config);
8487

8588
// add to total time spent

0 commit comments

Comments
 (0)