Remove need for luxon library

This commit is contained in:
Rene Saarsoo 2020-10-03 18:45:26 +03:00
parent 48347baca4
commit 62723823ed
3 changed files with 7 additions and 14 deletions

View File

@ -10,7 +10,6 @@
"@types/node": "^12.0.0", "@types/node": "^12.0.0",
"@types/react": "^16.9.0", "@types/react": "^16.9.0",
"@types/react-dom": "^16.9.0", "@types/react-dom": "^16.9.0",
"luxon": "^1.25.0",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-scripts": "3.4.3", "react-scripts": "3.4.3",
@ -39,7 +38,6 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"@types/luxon": "^1.25.0",
"@types/styled-components": "^5.1.3" "@types/styled-components": "^5.1.3"
} }
} }

View File

@ -1,9 +1,14 @@
import React from 'react'; import React from 'react';
import { stats, Workout, Duration, Intensity } from 'make-workout'; import { stats, Workout, Duration, Intensity } from 'make-workout';
import { Duration as LuxonDuration } from 'luxon';
const splitDuration = (duration: Duration) => ({
hours: Math.floor(duration.seconds / 60 / 60),
minutes: Math.floor(duration.seconds / 60) % 60,
seconds: duration.seconds % 60,
});
const formatDuration = (duration: Duration): string => { const formatDuration = (duration: Duration): string => {
const {hours, minutes, seconds} = LuxonDuration.fromObject({seconds: duration.seconds}).shiftTo('hours', 'minutes', 'seconds'); const {hours, minutes, seconds} = splitDuration(duration);
if (hours > 0) { if (hours > 0) {
return `${hours}h ${minutes}min`; return `${hours}h ${minutes}min`;
} }

View File

@ -1622,11 +1622,6 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"
integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw== integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==
"@types/luxon@^1.25.0":
version "1.25.0"
resolved "https://registry.yarnpkg.com/@types/luxon/-/luxon-1.25.0.tgz#3d6fe591fac874f48dd225cb5660b2b785a21a05"
integrity sha512-iIJp2CP6C32gVqI08HIYnzqj55tlLnodIBMCcMf28q9ckqMfMzocCmIzd9JWI/ALLPMUiTkCu1JGv3FFtu6t3g==
"@types/minimatch@*": "@types/minimatch@*":
version "3.0.3" version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
@ -6681,11 +6676,6 @@ lru-cache@^5.1.1:
dependencies: dependencies:
yallist "^3.0.2" yallist "^3.0.2"
luxon@^1.25.0:
version "1.25.0"
resolved "https://registry.yarnpkg.com/luxon/-/luxon-1.25.0.tgz#d86219e90bc0102c0eb299d65b2f5e95efe1fe72"
integrity sha512-hEgLurSH8kQRjY6i4YLey+mcKVAWXbDNlZRmM6AgWDJ1cY3atl8Ztf5wEY7VBReFbmGnwQPz7KYJblL8B2k0jQ==
make-dir@^2.0.0, make-dir@^2.1.0: make-dir@^2.0.0, make-dir@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"