@@ -7,6 +7,7 @@ const Time = require('./time');
77const regex = / a d d e d ( .* ) o f t i m e s p e n t (?: a t ( .* ) ) ? / i;
88const subRegex = / s u b t r a c t e d ( .* ) o f t i m e s p e n t (?: a t ( .* ) ) ? / i;
99const removeRegex = / R e m o v e d t i m e s p e n t / i;
10+ const delRegex = / d e l e t e d ( .* ) o f s p e n t t i m e f r o m ( .* ) / i;
1011
1112/**
1213 * base model for models that have times
@@ -68,21 +69,26 @@ 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+ let created = moment ( note . created_at ) , match , subMatch , delMatch ;
7273
7374 if ( //
7475 // filter out user notes
7576 ! note . system ||
7677 // filter out notes that are no time things
77- ! ( match = regex . exec ( note . body ) ) && ! ( subMatch = subRegex . exec ( note . body ) ) && ! removeRegex . exec ( note . body )
78+ ! ( match = regex . exec ( note . body ) ) && ! ( subMatch = subRegex . exec ( note . body ) ) && ! ( delMatch = delRegex . exec ( note . body ) ) && ! removeRegex . exec ( note . body )
7879 ) return done ( ) ;
7980
8081 // change created date when explicitly defined
8182 if ( match && match [ 2 ] ) created = moment ( match [ 2 ] ) ;
8283 if ( subMatch && subMatch [ 2 ] ) created = moment ( subMatch [ 2 ] ) ;
84+ if ( delMatch && delMatch [ 2 ] ) created = moment ( delMatch [ 2 ] ) ;
85+
86+ // collect minus items
87+ let minusFlag = subMatch | delMatch ;
88+ let minusMatch = minusFlag ? subMatch ? subMatch [ 1 ] : delMatch ? delMatch [ 1 ] : 0 : 0 ;
8389
8490 // create a time string and a time object
85- let timeString = match ? match [ 1 ] : ( subMatch ? `-${ subMatch [ 1 ] } ` : `-${ Time . toHumanReadable ( timeSpent ) } ` ) ;
91+ let timeString = match ? match [ 1 ] : ( minusMatch ? `-${ minusMatch } ` : `-${ Time . toHumanReadable ( timeSpent ) } ` ) ;
8692 let time = new Time ( null , created , note , this , this . config ) ;
8793 time . seconds = Time . parse ( timeString , 8 , 5 , 4 ) ;
8894
0 commit comments