tonyaellie / time-morph Goto Github PK
View Code? Open in Web Editor NEWTimeMorph is a lightweight package for converting between different time units in JavaScript.
License: MIT License
TimeMorph is a lightweight package for converting between different time units in JavaScript.
License: MIT License
The current implementation of the convertTime
function requires the duration and source unit of time to be specified in a single object. However, it would be beneficial to enhance the function to accept an input object that separates the duration into individual properties for different time units. For example, { minutes: 5, seconds: 40 }
instead of { duration: 340, unit: 'sec' }
.
This change would provide a more flexible and intuitive API for users, allowing them to directly specify the duration using a combination of different time units. Additionally, it would eliminate the need for users to calculate the duration manually when dealing with complex time conversions.
Modify the convertTime
function to accept an input object that separates the duration into individual properties for different time units. The updated function signature could look as follows:
convertTime(input: { minutes?: number, seconds?: number, hours?: number, ... }, output?: UnitOfTime): number;
In this updated signature, the input object can contain properties for different time units such as minutes
, seconds
, hours
, and so on. The function will convert the specified duration into milliseconds by summing up the individual time units and return the result.
import { convertTime } from 'time-morph';
const durationInMilliseconds = convertTime({ minutes: 5, seconds: 40 }); // 340000
const durationInSeconds = convertTime({ hours: 2, minutes: 30, seconds: 15 }, 'seconds'); // 9015
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.