This repository was archived by the owner on Dec 26, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
screens/hours/components/TotalHours Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ export function msToTime(s: number, showSeconds: boolean = true) {
1414 if ( ! s ) {
1515 return '0s' ;
1616 }
17+ const sign = s < 0 ? '-' : '' ;
18+ s = Math . abs ( s ) ;
1719 const ms = s % 1000 ;
1820 s = ( s - ms ) / 1000 ;
1921 const secs = s % 60 ;
@@ -30,7 +32,7 @@ export function msToTime(s: number, showSeconds: boolean = true) {
3032 if ( hrs === 0 && mins === 0 ) {
3133 return onlySecs ( secs ) ;
3234 }
33- return `${ timePad ( hrs ) } :${ timePad ( mins ) } ` ;
35+ return `${ sign } ${ timePad ( hrs ) } :${ timePad ( mins ) } ` ;
3436}
3537
3638export function calcDuration ( taskTime : ITimeRangeModel [ ] ) : number {
@@ -65,7 +67,7 @@ export function getTime(date: Date | undefined) {
6567 return format ( date , TIME_FORMAT ) ;
6668}
6769
68- const EIGHT_HOURS = 8 * 60 * 60 * 1000 ;
70+ export const EIGHT_HOURS = 8 * 60 * 60 * 1000 ;
6971
7072export function estimateWorkingTimeEnd (
7173 startDate : Date | undefined ,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { Space } from 'antd';
55import * as TaskHooks from '../../../../hooks/TaskHooks' ;
66import TaskTimeItemModel from '../../../../models/TaskTimeItemModel' ;
77import {
8+ EIGHT_HOURS ,
89 estimateWorkingTimeEnd ,
910 getTime ,
1011 msToTime ,
@@ -20,14 +21,13 @@ const TotalHours = observer((props: TotalHoursProps) => {
2021 const { timeItems } = props ;
2122 const classes = useStyle ( ) ;
2223
23- console . log ( ) ;
24-
2524 const { durationMs, gapsMs } = TaskHooks . useTimeItemsDuration ( timeItems ) ;
2625 const startWorkingTime = TaskHooks . useStartWorkingTime ( timeItems ) ;
2726 const estimatedWorkingTimeEnd = estimateWorkingTimeEnd (
2827 startWorkingTime ,
2928 gapsMs
3029 ) ;
30+ const restHoursMs = EIGHT_HOURS - durationMs ;
3131
3232 if ( ! timeItems . length ) {
3333 return null ;
@@ -48,6 +48,7 @@ const TotalHours = observer((props: TotalHoursProps) => {
4848 < span className = { clsx ( 'mi mi-notifications' , classes . icon ) } />
4949 < span > { getTime ( estimatedWorkingTimeEnd ) } </ span >
5050 </ div >
51+ < span > { msToTime ( restHoursMs , false ) } </ span >
5152 </ Space >
5253 ) ;
5354} ) ;
You can’t perform that action at this time.
0 commit comments