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-str

v1.0.2

Published

Converts Date object to string with some format

Downloads

6

Readme

Installation

Open your project's directory and execute next command:

npm install --save datetime-str

Including to your project

In order to use package in your project it should be assigned to the variable

const datetime_str = require('datetime-str');

Next command will create variable datetime_str that will hold module

Structure

API

monthNames - names of months from January

Type: array

Length: 12

Values:

[
    'January',
    'February',
    'March',
    'April',
    'May',
    'June',
    'July',
    'August',
    'September',
    'October',
    'November',
    'December'
]

monthNamesPart - first 3 symbols of months names

Type: array

Length: 12

Values:

[
    'Jan',
    'Feb',
    'Mar',
    'Apr',
    'May',
    'Jun',
    'Jul',
    'Aug',
    'Sep',
    'Oct',
    'Nov',
    'Dec'
]

dayNames - Names of days of week starting from Sunday

Type: array

Length: 7

Values:

[
    'Sunday',
    'Monday',
    'Tuesday',
    'Wednessday',
    'Thursday',
    'Friday',
    'Saturday'
]

dayNamesPart - first 3 symbols of day names

Type: array

Length: 7

Values:

[
    'Sun',
    'Mon',
    'Tue',
    'Wed',
    'Thu',
    'Fri',
    'Sat'
]

formats - Contains list of standart patterns

Type: object

Keys: default, en, ru

default format

{
    'full'       : '{yyyy mmmm d HH:MM:SS} UTC {UTC}',
    'datetime'   : '{yyyy-mm-dd HH:MM:SS}',
    'datetime12' : '{yyyy-mm-dd HH12:MM:SS AMPM}',

    'date'       : '{yyyy-mm-dd}',
    'time'       : '{HH:MM:SS}',
    'time12'     : '{HH12:MM:SS AMPM',

    'precise'    : 'SS.LL' 
}

us format

{
    'full'       : '{mmmm d yyyy HH:MM:SS} UTC {UTC}',
    'datetime'   : '{mm/dd/yyyy HH:MM:SS}',
    'datetime12' : '{mm/dd/yyyy HH12:MM:SS ampm}',
    'date'       : '{mm/dd/yyyy}'
}

ru format

{
    'full'       : '{yyyy mmmm d HH:MM:SS} UTC {UTC}',
    'datetime'   : '{dd.mm.yyyy HH:MM:SS}',
    'datetime12' : '{dd.mm.yyyy HH12:MM:SS ampm}',
    'date'       : '{dd.mm.yyyy}'
}

Formating

format(pattern, date) - Formats date using pattern

pattern - string

date - standart Date object

Starting with patterns

Pattern is a simple string that can contains any symbols

To designate where formated date should be placed {}(curly braces) are used

Simple pattern that shows current time will be:

'Current time is {HH} hours {MM} minutes {SS} seconds'

It is possible to use multiple keys within {}(curly braces)

'Current time: {HH:MM:SS}`

They can be splited by any not alpha-numeric symbols

List of possible keys

Date - numbers

yyyy - full year. Example: 2002

yy - two-digit year with leading zero. Example: 02

y - two-digit year without leading zero. Example: 2

mm - month with leading zero

m - month without leading zero

dd - day with leading zero

d - day without leading zero

Date - strings

mmmm - Month name. Full form

mmm - Month name. Only first 3 symbols

dddd - Day of week. Full form

ddd - Day of week. Only first 3 symbols

Time

HH24 - 24 hours time with leading zero

HH - 24 hours time with leading zero. Shortcut

HH12 - 12 hours time with leading zero. Should be used together with ampm

H24 - 24 hours time without leading zero

H - 24 hours time without leading zero. Shortcut

H12 - 12 hours time without leading zero. Should be used together with ampm

MM - Minutes with leading zero

M - Minutes without leading zero

SS - Seconds with leading zero

S - Seconds without leading zero

LL - Milliseconds with leading zero

L - Milliseconds without leading zero

Special

ampm - Current half of the day as am or pm

AMPM - Current half of the day as AM or PM

UTC - Time zone offset. Example +1 or -2:30