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 🙏

© 2024 – Pkg Stats / Ryan Hefner

timelite

v1.0.0

Published

String date and time utilities

Downloads

1,568

Readme

Timelite Build Status npm npm JavaScript Style Guide

String date and time utilities.

API

Time

  • [x] add : Add an array of string times. Eg. add(['04:20:10', '21:15:10'])
  • [x] str : Format an array of time values into string time. Eg. str([12, 0, 45]) => [ 12, 00, 45 ]
  • [x] sub : Subtract an array of string times. Eg. sub(['20:05:10', '10:10:50']) => [ 9, 54, 20 ]

Date

  • [x] normalize : Normalize string date values returning a valid date as an unsigned integer array.
  • [x] str : Format an array date values into a valid string date.

Install

Yarn

yarn add timelite --dev

NPM

npm install timelite --save-dev

UMD file is also available on unpkg:

<script src="https://unpkg.com/timelite/timelite.umd.min.js"></script>

You can use the library via window.timelite.

Usage

Time

add

Add an array of string time values "HH:mm:ss".

import { add } from 'timelite/time'

add(['04:20:10', '21:15:10'])
// [ 25, 35, 2 ]
add(['04:35:10', '21:35:10'])
// [ 26, 10, 2 ]
add(['30:59', '17:10'])
// [ 48, 09, 0 ]
add(['19:30:00', '00:30:00'])
// [ 20, 00, 0 ]

sub

Subtract an array of string time values "HH:mm:ss".

import { sub } from 'timelite/time'

sub(['20:40:10', '20:10:50'])
// [ 0, 29, 20 ]
sub(['20:05:10', '10:10:50'])
// [ 9, 54, 20 ]

str

Format an array time values into string time.

import { str } from 'timelite/time'

str([12, 10, 45])
// "12:10:45"
str([5, 1, 0])
// "05:01:00"
str([7, 22])
// "07:22:00"

Date

normalize

Normalize string date values returning a valid date as an unsigned integer array.

import { normalize } from 'timelite/date'

normalize('1980-09-02')
// [ 1980, 9, 2 ]
normalize('17')
// [ 2017, 1, 1 ]
normalize('18-04')
// [ 2018, 4, 1 ]
normalize('0-02-31')
// [ 2000, 2, 28 ]

str

Format an array date values into a valid string date.

import { str } from 'timelite/date'

str([ 0, 0, 0 ])
// 2000-01-01
str([ 17, 14, 5 ])
// 2017-12-05
str([ 1988, 2 ])
// 1988-02-01

Contributions

Feel free to send some Pull request or issue.

License

MIT license

© 2018 José Luis Quintana