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

datetime-next

v1.2.6

Published

--- Next gen Date and Time manipulation library designed with performance in mind, it is **extremely lightweight**. It is about 3.5Kb minified and gzipped.

Downloads

4

Readme

DateTime Next


Next gen Date and Time manipulation library designed with performance in mind, it is extremely lightweight. It is about 3.5Kb minified and gzipped.

Does not use any static data such as localization files, everything comes from built in Intl object. However, this can be overridden if you provide your own Month names.

DateTime is designed to only operate on UTC date and time. It has however support for formatting date and time in user specified locale and timezone.

DateTime is specifically built as Mutable object, if you wish to use immutable object use DateTimeImmutable instead. Read more about this choice here

Zero dependencies.

npm

WARNING: API is not yet final

Requirements

Technically it should have no requirements, For node recommended version 8+. For browser, it's the existence of Intl object.


Docs

Read the docs here


Installation

For yarn:

yarn add datetime-next

For npm:

npm i datetime-next

For browser just include the script or import it via ES6 import statement.

Some examples


Imports:

// ES6 JS/Typescript style
import { DateTime } from 'datetime-next';
// OR
import { DateTime } from 'datetime-next/DateTime';

// require

const { DateTime } = require('datetime-next');

Basic usage:

const dt = new DateTime(); // Current datetime in UTC
dt.addHour(1); // Add one hour
dt.getString('YYYY-MM-DD'); // format date ex `2021-06-21`
dt.getString('HH:mm:ss'); // format time `15:25:41`

Format properties:

| Symbol | Description | Example | | :------ | :------ | :------ | | YY | Year in 2 digit format | 21 | | YYYY | Year in full format | 2021 | | M | Month digit not padded with zeros | 4 | | MM | Month padded to 2 digits | 04 | | MMM | Short locale aware month name | Dec | | MMMM | Long locale aware month name | December | | d | Weekday number | 5 | | dd | Weekday locale aware narrow name | F | | ddd | Weekday locale aware short name | Fri | | dddd | Weekday locale aware short name | Friday | | D | Day of month not padded | 9 | | DD | Day of month padded to 2 digits | 09 | | H | Hour in 24h format not padded | 7 | | HH | Hour in 24h format padded to 2 digits | 07 | | h | Hour in 12h format not padded | 7 | | hh | Hour in 12h format padded to 2 digits | 07 | | a | Meridian locale aware in lowercase | am | | A | Meridian locale aware in uppercase | AM | | m | Minute not padded | 5 | | mm | Minute padded to 2 digits | 05 | | s | Second not padded | 3 | | ss | Second padded to 2 digits | 03 | | SSS | Milliseconds padded to 3 digits | 245 | | Z | Timezone offset from UTC with colon | +02:00 | | ZZ | Timezone offset from UTC without colon | +02:00 |