@@ -4,8 +4,8 @@ const moment = require('moment');
44const Base = require ( './base' ) ;
55const Time = require ( './time' ) ;
66
7- const regex = / a d d e d ( .* ) o f t i m e s p e n t / i;
8- const subRegex = / s u b t r a c t e d ( .* ) o f t i m e s p e n t / i;
7+ const regex = / a d d e d ( .* ) o f t i m e s p e n t (?: a t ( . * ) ) ? / i;
8+ const 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;
1010
1111/**
@@ -70,17 +70,20 @@ class hasTimes extends Base {
7070 let promise = this . parallel ( this . notes , ( note , done ) => {
7171 let created = moment ( note . created_at ) , match , subMatch ;
7272
73-
7473 if ( //
7574 // filter out user notes
7675 ! note . system ||
7776 // filter out notes that are no time things
7877 ! ( match = regex . exec ( note . body ) ) && ! ( subMatch = subRegex . exec ( note . body ) ) && ! removeRegex . exec ( note . body )
7978 ) return done ( ) ;
8079
80+ // change created date when explicitly defined
81+ if ( match && match [ 2 ] ) created = moment ( match [ 2 ] ) ;
82+ if ( subMatch && subMatch [ 2 ] ) created = moment ( subMatch [ 2 ] ) ;
83+
8184 // create a time string and a time object
8285 let timeString = match ? match [ 1 ] : ( subMatch ? `-${ subMatch [ 1 ] } ` : `-${ Time . toHumanReadable ( timeSpent , this . config . get ( 'hoursPerDay' ) ) } ` ) ;
83- let time = new Time ( timeString , note , this , this . config ) ;
86+ let time = new Time ( timeString , created , note , this , this . config ) ;
8487
8588 // add to total time spent
8689 totalTimeSpent += time . seconds ;
@@ -124,7 +127,7 @@ class hasTimes extends Base {
124127 let difference = this . data . time_stats . total_time_spent - totalTimeSpent ,
125128 note = Object . assign ( { noteable_type : this . _typeSingular } , this . data ) ;
126129
127- times . unshift ( new Time ( Time . toHumanReadable ( difference , this . config . get ( 'hoursPerDay' ) ) , note , this , this . config ) ) ;
130+ times . unshift ( new Time ( Time . toHumanReadable ( difference , null , this . config . get ( 'hoursPerDay' ) ) , note , this , this . config ) ) ;
128131
129132 resolve ( ) ;
130133 } ) ) ;
0 commit comments