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

@zuude-ui/video

v0.1.27

Published

A comprehensive video player library with advanced time formatting utilities.

Downloads

120

Readme

@zuude-ui/video

A comprehensive video player library with advanced time formatting utilities.

Video Time Formatting Utilities

Similar to date-fns but specifically designed for video durations and time formatting.

Basic Usage

import { formatTime, humanizeTime, parseTime } from "@zuude-ui/video/utils";

// Basic formatting
formatTime(125.5); // "2:05"
formatTime(125.5, "h:mm:ss"); // "0:02:05"
formatTime(125.5, "ss"); // "125s"

// Human readable
humanizeTime(125.5); // "2 minutes 5 seconds"
humanizeTime(125.5, { compact: true }); // "2 minutes"

// Parse time strings
parseTime("2:30"); // 150
parseTime("1:23:45"); // 5025
parseTime("90s"); // 90

Available Functions

formatTime(time, options)

Format time in seconds to various formats.

Parameters:

  • time (number): Time in seconds
  • options (TimeFormatOptions | TimeFormat): Format options

Formats:

  • "mm:ss" (default): "2:05"
  • "h:mm:ss": "0:02:05"
  • "ss": "125s"
  • "human": "2 minutes 5 seconds"
  • "compact": "2:05"
  • "detailed": "00:02:05.000"

Options:

interface TimeFormatOptions {
  format?: TimeFormat;
  showHours?: boolean;
  showLeadingZeros?: boolean;
  showMilliseconds?: boolean;
  humanize?: boolean;
  compact?: boolean;
}

humanizeTime(time, options)

Convert time to human-readable format.

humanizeTime(125.5); // "2 minutes 5 seconds"
humanizeTime(125.5, { compact: true }); // "2 minutes"
humanizeTime(3600); // "1 hour"

compactTime(time)

Compact time format.

compactTime(125.5); // "2:05"
compactTime(3600); // "1:00:00"

detailedTime(time, options)

Detailed time format with optional milliseconds.

detailedTime(125.5); // "00:02:05"
detailedTime(125.5, { showMilliseconds: true }); // "00:02:05.000"

parseTime(timeString)

Parse time string to seconds.

parseTime("2:30"); // 150
parseTime("1:23:45"); // 5025
parseTime("90s"); // 90
parseTime("1.5m"); // 90
parseTime("0.5h"); // 1800

timeRemaining(current, total, format)

Calculate remaining time.

timeRemaining(125.5, 3600); // "57:54"
timeRemaining(125.5, 3600, "human"); // "57 minutes 54 seconds"

formatTimeWithPercentage(current, total, format)

Format time with percentage.

formatTimeWithPercentage(125.5, 3600); // "2:05 (3%)"

getTimeSegments(duration, segments)

Get time segments for timeline.

getTimeSegments(3600, 5); // [0, 720, 1440, 2160, 2880, 3600]

formatTimeForAccessibility(time)

Format time for screen readers.

formatTimeForAccessibility(125.5); // "2 minutes, 5 seconds"

Advanced Examples

Custom Timeline Component

import { formatTime, getTimeSegments } from "@zuude-ui/video/utils";

const Timeline = ({ currentTime, duration }) => {
  const segments = getTimeSegments(duration, 10);

  return (
    <div className="timeline">
      {segments.map((time, i) => (
        <div key={i} className="segment">
          {formatTime(time, "mm:ss")}
        </div>
      ))}
    </div>
  );
};

Video Progress Display

import {
  formatTime,
  timeRemaining,
  formatTimeWithPercentage,
} from "@zuude-ui/video/utils";

const VideoProgress = ({ currentTime, duration }) => {
  return (
    <div className="video-progress">
      <span>{formatTime(currentTime)}</span>
      <span>{timeRemaining(currentTime, duration)}</span>
      <span>{formatTimeWithPercentage(currentTime, duration)}</span>
    </div>
  );
};

Accessibility-Friendly Time Display

import { formatTimeForAccessibility } from "@zuude-ui/video/utils";

const AccessibleTimeDisplay = ({ time }) => {
  return (
    <span aria-label={formatTimeForAccessibility(time)}>
      {formatTime(time)}
    </span>
  );
};

Comparison with Other Libraries

| Feature | @zuude-ui/video | date-fns | humanize-duration | | ------------------ | --------------- | -------- | ----------------- | | Video-specific | ✅ | ❌ | ❌ | | Multiple formats | ✅ | ✅ | ❌ | | Time parsing | ✅ | ❌ | ❌ | | Accessibility | ✅ | ❌ | ❌ | | Percentage display | ✅ | ❌ | ❌ | | Time segments | ✅ | ❌ | ❌ | | Bundle size | Small | Large | Medium |

Installation

npm install @zuude-ui/video
# or
yarn add @zuude-ui/video
# or
pnpm add @zuude-ui/video

TypeScript Support

Full TypeScript support with comprehensive type definitions:

import type { TimeFormat, TimeFormatOptions } from "@zuude-ui/video/utils";

Video Player Components

The library also includes a complete video player with hooks and components. See the main documentation for video player usage.