All Projects → cmaurer → relative.time.parser

cmaurer / relative.time.parser

Licence: MIT license
Moment.js Plugin for parsing Relative Time Strings

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to relative.time.parser

Dayjs
⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API
Stars: ✭ 37,373 (+287384.62%)
Mutual labels:  time, date, moment
imrc-datetime-picker
(Improved) React component datetime picker by momentjs 📆
Stars: ✭ 21 (+61.54%)
Mutual labels:  date, moment, momentjs
format-date
📆 A small library (around 400 B when gziped & minified) to format JavaScript `Date` object using same tokens as moment.
Stars: ✭ 25 (+92.31%)
Mutual labels:  date, moment, momentjs
moment-cache
⏱ Simple utility to cache moment.js results and speed up moment calls.
Stars: ✭ 29 (+123.08%)
Mutual labels:  time, date, moment
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+4023.08%)
Mutual labels:  time, date, moment
dayjs
Extended fork of Day.js - 2KB immutable date library alternative to Moment.js
Stars: ✭ 36 (+176.92%)
Mutual labels:  time, date, moment
chronos
One library to rule the time
Stars: ✭ 17 (+30.77%)
Mutual labels:  time, date, moment
Moment.php
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Stars: ✭ 900 (+6823.08%)
Mutual labels:  time, date, moment
Moment Range
Fancy date ranges for Moment.js
Stars: ✭ 1,639 (+12507.69%)
Mutual labels:  time, date, moment
moment-recur-ts
Conversion of the moment-recur library into TypeScript.
Stars: ✭ 17 (+30.77%)
Mutual labels:  moment, momentjs
vue-translated
Internationalization (i18n) and localization (l10n) library for Vue.js v2.
Stars: ✭ 19 (+46.15%)
Mutual labels:  time, date
qrono
🕥 Just right date time library
Stars: ✭ 111 (+753.85%)
Mutual labels:  time, date
kronos
Management of arithmetic operations on dates
Stars: ✭ 23 (+76.92%)
Mutual labels:  time, date
rutimeparser
Recognize date and time in russian text and return datetime.datetime.
Stars: ✭ 17 (+30.77%)
Mutual labels:  time, date
time machine
A date and time API for Dart
Stars: ✭ 120 (+823.08%)
Mutual labels:  time, date
island-time
A Kotlin Multiplatform library for working with dates and times
Stars: ✭ 69 (+430.77%)
Mutual labels:  time, date
discord-clock
A simple clock script for your bot to show what time it is in your server | Discord.js v13 ready!
Stars: ✭ 29 (+123.08%)
Mutual labels:  moment, momentjs
scala-js-momentjs
Scala.js façade for Moment.js
Stars: ✭ 45 (+246.15%)
Mutual labels:  time, moment
TimesDates.jl
Nanosecond resolution for Time and Date, TimeZones
Stars: ✭ 28 (+115.38%)
Mutual labels:  time, date
FM-JSON-Types
FileMaker Data Types in JSON
Stars: ✭ 14 (+7.69%)
Mutual labels:  time, date

Relative Time Parser Plugin for Moment.js

This plugin converts a simple string to a manipulated moment object. The string format is inspired by Graphite's relative time format.

Badges

NPM npm downloads Build Status Dependency Status devDependency Status Maintainability Test Coverage Known Vulnerabilities

Install - NPM

npm install relative-time-parser

Usage

Using the string -7d would be equivalent of moment().subtract(7, 'days');, and similarly, using the string +7d would be equivalent of moment().add(7, 'days');. The specific abbreviations are listed in the table below.

var moment = require('relative-time-parser');
moment().relativeTime('-6h').format();

Patterns

ms - milliseconds

subtract milliseconds
moment().relativeTime('-6ms');
add milliseconds
moment().relativeTime('+6ms');

s - seconds

subtract seconds
moment().relativeTime('-6s');
add seconds
moment().relativeTime('+6s');

sec - seconds

subtract seconds
moment().relativeTime('-6sec');
add seconds
moment().relativeTime('+6sec');

second - seconds

subtract seconds
moment().relativeTime('-6second');
add seconds
moment().relativeTime('+6second');

seconds - seconds

subtract seconds
moment().relativeTime('-6seconds');
add seconds
moment().relativeTime('+6seconds');

m - minutes

subtract minutes
moment().relativeTime('-6m');
add minutes
moment().relativeTime('+6m');

min - minutes

subtract minutes
moment().relativeTime('-6min');
add minutes
moment().relativeTime('+6min');

minute - minutes

subtract minutes
moment().relativeTime('-6minute');
add minutes
moment().relativeTime('+6minute');

minutes - minutes

subtract minutes
moment().relativeTime('-6minutes');
add minutes
moment().relativeTime('+6minutes');

h - hours

subtract hours
moment().relativeTime('-6h');
add hours
moment().relativeTime('+6h');

hour - hours

subtract hours
moment().relativeTime('-6hour');
add hours
moment().relativeTime('+6hour');

hours - hours

subtract hours
moment().relativeTime('-6hours');
add hours
moment().relativeTime('+6hours');

d - days

subtract days
moment().relativeTime('-6d');
add days
moment().relativeTime('+6d');

day - days

subtract days
moment().relativeTime('-6day');
add days
moment().relativeTime('+6day');

w - weeks

subtract weeks
moment().relativeTime('-6w');
add weeks
moment().relativeTime('+6w');

week - weeks

subtract weeks
moment().relativeTime('-6week');
add weeks
moment().relativeTime('+6week');

weeks - weeks

subtract weeks
moment().relativeTime('-6weeks');
add weeks
moment().relativeTime('+6weeks');

mon - months

subtract months
moment().relativeTime('-6mon');
add months
moment().relativeTime('+6mon');

month - months

subtract months
moment().relativeTime('-6month');
add months
moment().relativeTime('+6month');

months - months

subtract months
moment().relativeTime('-6months');
add months
moment().relativeTime('+6months');

M - months

subtract months
moment().relativeTime('-6M');
add months
moment().relativeTime('+6M');

Q - quarters

subtract quarters
moment().relativeTime('-6Q');
add quarters
moment().relativeTime('+6Q');

Quarter - quarters

subtract quarters
moment().relativeTime('-6Quarter');
add quarters
moment().relativeTime('+6Quarter');

Quarters - quarters

subtract quarters
moment().relativeTime('-6Quarters');
add quarters
moment().relativeTime('+6Quarters');

y - years

subtract years
moment().relativeTime('-6y');
add years
moment().relativeTime('+6y');

year - years

subtract years
moment().relativeTime('-6year');
add years
moment().relativeTime('+6year');

years - years

subtract years
moment().relativeTime('-6years');
add years
moment().relativeTime('+6years');

now - now

moment().relativeTime('now');

Is Relative Time String Format

Tests a String to determine if it is in the RelativeTimeFormat

moment().isRelativeTimeFormat('-2y'); // should === true
moment().isRelativeTimeFormat('xxx'); // should === false
moment().isRelativeTimeFormat('now'); // should === true

Resources

Graphite URL Api Reference

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].