File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import {
55import dayjs from 'dayjs' ;
66import relativeTime from 'dayjs/plugin/relativeTime' ;
77import updateLocale from 'dayjs/plugin/updateLocale' ;
8+ import duration from 'dayjs/plugin/duration' ;
89
910dayjs . extend ( updateLocale ) ;
1011dayjs . extend ( relativeTime ) ;
12+ dayjs . extend ( duration ) ;
1113
1214const reEmail = / ( .+ ?) @ ( .+ ?) / ig;
1315const prefKey = 'listmonk_pref' ;
@@ -71,11 +73,15 @@ export default class Utils {
7173 duration = ( start , end ) => {
7274 const a = dayjs ( start ) ;
7375 const b = dayjs ( end ) ;
76+ const d = dayjs . duration ( Math . abs ( b . diff ( a ) ) ) ;
7477
75- // Get the duration string, eg: "2 days".
76- const diff = b . from ( a , true ) ;
78+ const parts = [
79+ Math . floor ( d . asDays ( ) ) && `${ Math . floor ( d . asDays ( ) ) } d` ,
80+ d . hours ( ) && `${ d . hours ( ) } h` ,
81+ d . minutes ( ) && `${ d . minutes ( ) } m` ,
82+ ] . filter ( Boolean ) ;
7783
78- return `${ b . isBefore ( a ) ? '-' : '' } ${ diff } ` ;
84+ return `${ b . isBefore ( a ) ? '-' : '' } ${ parts . join ( ' ' ) } ` ;
7985 } ;
8086
8187 // Simple, naive, e-mail address check.
Original file line number Diff line number Diff line change 145145 <label for =" #" ><b-icon icon =" speedometer" size =" is-small" /></label >
146146 <span class =" send-rate" >
147147 <b-tooltip
148- :label =" `${stats.netRate} / ${$t('campaigns.rateMinuteShort')} @
149- ${$utils.duration(stats.startedAt, stats.updatedAt)}`"
148+ :label =" `${stats.netRate} / ${$t('campaigns.rateMinuteShort')} @ ${$utils.duration(stats.startedAt, stats.updatedAt)}`"
150149 type =" is-dark" >
151150 {{ stats.rate.toFixed(0) }} / {{ $t('campaigns.rateMinuteShort') }}
152151 </b-tooltip >
You can’t perform that action at this time.
0 commit comments