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

moment-parser

v0.3.0

Published

moment parser that supports natural language expressions

Downloads

585

Readme

moment-parser

Build Status Join the chat at https://gitter.im/juttle/moment-parser

Natural language time parser for moment.js strings

Quick start

npm install moment-parser

var parser = require('moment-parser');

// durations
console.log(parser.parse('1 hour')); //{ type: 'MomentDuration', value: 1, unit: 'hour' }
console.log(parser.parseDuration('2 months and 1 day')); // a momentjs duration of { days: 1, months: 2 }

// moments
console.log(parser.parse('2015-01-01')); //{ type: 'ISODateLiteral', value: '2015-01-01T00:00:00' }
console.log(parser.parseMoment('day 5 of next month')); // a momentjs moment at the start of next month plus 4 days

More Examples In Tests

Running Unit Tests

npm test

More examples

(proper grammar docs coming soon!)

Absolute Moments

All times are UTC0 unless a time zone is specified by appending it to an ISO-8601 string. ​ ​

  • Midnight on a specific date (UTC0):
2014-09-21

2014-09-22T11:39:17.993

  • The same date and time, as Pacific Standard Time:
2014-09-22T03:39:17.993-08:00

Durations

  • One second, minute, hour, day, week, and so on:
second
minute
hour
day
week
month
year

​ Note that month and year are special "calendar" durations that do not have fixed length but instead advance whole months or years relative to a fixed moment. ​

  • Abbreviations for 0 seconds, 1 minute, 2 hours, 3 days, 4 weeks, 5 months, 6 years:
0s
1m
2h
3d
4w
5M
6y

  • Two ways to write one hour and twenty-three minutes:
 1 hour and 23 minutes
 01:23:00

  • Additional examples:
 1 second
 20 minutes

Relative Moments

  • The moment at which the program started running:
now

  • Midnight yesterday, today, or tomorrow:
yesterday
today
tomorrow

  • Seven hours after midnight on the current day:
07:00:00 after today

  • One minute from the start of the program's execution:
 1 minute from now

  • Shorter way to write 2 minutes from now:
+2m

  • Shorter way to write 1 hour and 10 minutes before now:
-01:10:00

  • Now minus 72 hours:
 3 days ago

  • Now minus 22 days:
 3 weeks and 1 day ago

  • Midnight of the first day of the current calendar month:
this month

  • Midnight of the first day of the previous calendar month:
last month

  • Midnight of the 20th day of the previous calendar month:
day 20 of last month

  • The minute in which the program began executing:
this minute

  • The next even hour after the start of the program's execution:
next hour

  • The day in which the program began executing:
this day
today

  • The day before the day in which the program began executing:
last day
yesterday