From 62723823ed42f7f9fa8dd8df764fc1617574b532 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Sat, 3 Oct 2020 18:45:26 +0300 Subject: [PATCH] Remove need for luxon library --- package.json | 2 -- src/components/WorkoutStats.tsx | 9 +++++++-- yarn.lock | 10 ---------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 34e858b..05c75a6 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "@types/node": "^12.0.0", "@types/react": "^16.9.0", "@types/react-dom": "^16.9.0", - "luxon": "^1.25.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.3", @@ -39,7 +38,6 @@ ] }, "devDependencies": { - "@types/luxon": "^1.25.0", "@types/styled-components": "^5.1.3" } } diff --git a/src/components/WorkoutStats.tsx b/src/components/WorkoutStats.tsx index 8c9912c..945878d 100644 --- a/src/components/WorkoutStats.tsx +++ b/src/components/WorkoutStats.tsx @@ -1,9 +1,14 @@ import React from 'react'; 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 {hours, minutes, seconds} = LuxonDuration.fromObject({seconds: duration.seconds}).shiftTo('hours', 'minutes', 'seconds'); + const {hours, minutes, seconds} = splitDuration(duration); if (hours > 0) { return `${hours}h ${minutes}min`; } diff --git a/yarn.lock b/yarn.lock index 9523bf5..b729d89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1622,11 +1622,6 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0" 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@*": version "3.0.3" resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" @@ -6681,11 +6676,6 @@ lru-cache@^5.1.1: dependencies: 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: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"