Fix missing overtime print
This commit is contained in:
parent
cd891bf6a0
commit
bb79ecdaa1
3 changed files with 7 additions and 7 deletions
|
@ -1,6 +1,5 @@
|
|||
import chalk from 'chalk';
|
||||
import { Duration } from 'dayjs/plugin/duration';
|
||||
import getConfig from './config';
|
||||
import { parseDuration, parseTimestamp } from './parse';
|
||||
import * as readline from 'readline/promises';
|
||||
import { formatDuration, formatTime } from './format';
|
||||
|
@ -110,10 +109,10 @@ const input = async (config: WtcConfig): Promise<WtcPromptResult> => {
|
|||
const unLogged = worked.subtract(logged);
|
||||
const workLeft = workDayDuration.subtract(worked);
|
||||
let workLeftMinutes = workLeft.asMinutes();
|
||||
let workedOverTime: Duration | undefined;
|
||||
let workedOvertime: Duration | undefined;
|
||||
|
||||
if (workLeftMinutes < 0) {
|
||||
workedOverTime = dayjs.duration(Math.round(workLeftMinutes * -1), 'minutes');
|
||||
workedOvertime = dayjs.duration(Math.round(workLeftMinutes * -1), 'minutes');
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -125,6 +124,7 @@ const input = async (config: WtcConfig): Promise<WtcPromptResult> => {
|
|||
hadLunch,
|
||||
worked,
|
||||
workLeft,
|
||||
workedOvertime,
|
||||
};
|
||||
} finally {
|
||||
rl.close();
|
||||
|
|
|
@ -10,7 +10,7 @@ const output = (result: WtcPromptResult, config: WtcConfig) => {
|
|||
const msg = message(config.language);
|
||||
const fmtDuration = formatDuration(config.language);
|
||||
const hoursRounded = getHoursRoundedStr(config.language);
|
||||
const { startedAt, stoppedAt, stoppedWorking, worked, unLogged, workLeft, workedOverTime } = result;
|
||||
const { startedAt, stoppedAt, stoppedWorking, worked, unLogged, workLeft, workedOvertime } = result;
|
||||
log();
|
||||
log(msg(MessageKey.startedWorking), formatTimestamp(startedAt));
|
||||
log(
|
||||
|
@ -33,8 +33,8 @@ const output = (result: WtcPromptResult, config: WtcConfig) => {
|
|||
|
||||
if (workLeft.asMinutes() > 0) {
|
||||
log(msg(MessageKey.workLeft, chalk.green(fmtDuration(workLeft))));
|
||||
} else if (workedOverTime) {
|
||||
log(msg(MessageKey.workedOvertime, chalk.green(fmtDuration(workedOverTime))));
|
||||
} else if (workedOvertime) {
|
||||
log(msg(MessageKey.workedOvertime, chalk.green(fmtDuration(workedOvertime))));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,5 +10,5 @@ export interface WtcPromptResult {
|
|||
hadLunch: boolean;
|
||||
worked: Duration;
|
||||
workLeft: Duration;
|
||||
workedOverTime?: Duration;
|
||||
workedOvertime?: Duration;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue