Giter Club home page Giter Club logo

time-morph's People

Contributors

github-actions[bot] avatar tonyaellie avatar

Stargazers

 avatar

Watchers

 avatar

time-morph's Issues

Proposal: Enhance convertTime to Accept Multiple Formats Simultaneously

Issue Description

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.

Proposed Solution

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.

Example Usage

import { convertTime } from 'time-morph';

const durationInMilliseconds = convertTime({ minutes: 5, seconds: 40 }); // 340000
const durationInSeconds = convertTime({ hours: 2, minutes: 30, seconds: 15 }, 'seconds'); // 9015

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.