Skip to content

Commit

Permalink
remove parse-ms
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Jan 1, 2023
1 parent c3f88ae commit e3b6a33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions interface/src/project/DashboardData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ import {

import { useI18nContext } from '../i18n/i18n-react';

import parseMilliseconds from 'parse-ms';

const DashboardData: FC = () => {
const { me } = useContext(AuthenticatedContext);

Expand Down Expand Up @@ -401,7 +399,10 @@ const DashboardData: FC = () => {
const isCmdOnly = (dv: DeviceValue) => dv.v === '' && dv.c;

const formatDurationMin = (duration_min: number) => {
const { days, hours, minutes } = parseMilliseconds(duration_min * 60000);
const days = Math.trunc((duration_min * 60000) / 86400000);
const hours = Math.trunc((duration_min * 60000) / 3600000) % 24;
const minutes = Math.trunc((duration_min * 60000) / 60000) % 60;

let formatted = '';
if (days) {
formatted += LL.NUM_DAYS({ num: days }) + ' ';
Expand Down
7 changes: 5 additions & 2 deletions interface/src/project/DashboardStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import * as EMSESP from './api';

import type { Translation } from '../i18n/i18n-types';
import { useI18nContext } from '../i18n/i18n-react';
import parseMilliseconds from 'parse-ms';

export const isConnected = ({ status }: Status) => status !== busConnectionStatus.BUS_STATUS_OFFLINE;

Expand Down Expand Up @@ -157,7 +156,11 @@ const DashboardStatus: FC = () => {
};

const formatDurationSec = (duration_sec: number) => {
const { days, hours, minutes, seconds } = parseMilliseconds(duration_sec * 1000);
const days = Math.trunc((duration_sec * 1000) / 86400000);
const hours = Math.trunc((duration_sec * 1000) / 3600000) % 24;
const minutes = Math.trunc((duration_sec * 1000) / 60000) % 60;
const seconds = Math.trunc((duration_sec * 1000) / 1000) % 60;

let formatted = '';
if (days) {
formatted += LL.NUM_DAYS({ num: days }) + ' ';
Expand Down

0 comments on commit e3b6a33

Please sign in to comment.