npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

start-end-time-duration-calculator

v1.0.1

Published

A package to calculate end time or start time based on duration

Readme

Time Calculator

A simple NPM package to calculate end time based on a start time and duration, or start time based on an end time and duration. This is especially useful for scheduling applications and time management tools.

Installation

To install the package, use the following command:

npm install time-calculator

Usage

Importing the Package

const { calculateEndTime, calculateStartTime } = require('time-calculator');

Functions

calculateEndTime(startTime, duration)

  • startTime: A string representing the start time in ISO format.
  • duration: A number representing the duration in minutes.

Returns: A string representing the end time in ISO format.

const endTime = calculateEndTime('2024-12-11T10:00:00Z', 120);
console.log(endTime); // '2024-12-11T12:00:00.000Z'

calculateStartTime(endTime, duration)

  • endTime: A string representing the end time in ISO format.
  • duration: A number representing the duration in minutes.

Returns: A string representing the start time in ISO format.

const startTime = calculateStartTime('2024-12-11T12:00:00Z', 120);
console.log(startTime); // '2024-12-11T10:00:00.000Z'

Use Cases

  1. Meeting Scheduling: Automatically calculate the end time of a meeting given its start time and duration, or vice versa.
  2. Task Management: Determine when you need to start a task to finish by a specific time.
  3. Event Planning: Plan events with precise start and end times.
  4. Movie Planning: Calculate the start time if you know the movie duration and the desired end time, ensuring you finish in time for other activities.
  5. Scheduling Timers for Electronic Devices: Set timers on devices like kitchen appliances or garden sprinklers by calculating the required start or end time based on the duration of use.

Handling Different Timezones

Example with IST (Indian Standard Time)

Indian Standard Time (IST) is UTC+5:30. You can handle time zones by adjusting the input times accordingly.

Using calculateEndTime in IST

const startTimeIST = new Date('2024-12-11T10:00:00Z').toLocaleString("en-US", {timeZone: "Asia/Kolkata"});
const duration = 120; // 2 hours
const endTimeUTC = calculateEndTime(startTimeIST, duration);

const endTimeIST = new Date(endTimeUTC).toLocaleString("en-US", {timeZone: "Asia/Kolkata"});
console.log('End Time in IST:', endTimeIST);

Using calculateStartTime in IST

const endTimeIST = new Date('2024-12-11T12:00:00Z').toLocaleString("en-US", {timeZone: "Asia/Kolkata"});
const duration = 120; // 2 hours
const startTimeUTC = calculateStartTime(endTimeIST, duration);

const startTimeIST = new Date(startTimeUTC).toLocaleString("en-US", {timeZone: "Asia/Kolkata"});
console.log('Start Time in IST:', startTimeIST);

Running Tests

To run the included tests, use the following command:

npm test

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

This project is licensed under the ISC License - see the LICENSE file for details.