This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

parsec

2.0.2 • Public • Published

ParSec

A duration parser and formatter to turn random garbage into program usable times.

Provides a clear, easy to use interface to parse strings into usable timings

Example:

Parsec('aug3 1920').format('{MONTH-NAME} {DAYS}{DAY-SUFFIX} {YEAR}') 
// August 3rd 1920

Documentation Navigation


Installation

NPM

Installing on NPM is simple, just open your terminal and run:

npm install parsec --save

Yarn

to install with Yarn, open your terminal and use:

yarn add parsec

Locales

Supported Locales

All languages supported by this module are translated to the best knowledge of the person submitting the translation, this means we are trying to get native speakers of the language to submit translations of time phrases in their local language,

Language Native Supported Since Translator
English English 0.0.1 Fatalcenturion

Planned Locales

This table contains languages which we are planning to implement into the module, but have not managed to do just yet. If you are a native speaker of any of the languages below and would like to help translate, please get in touch so we can send you a translation package.

Language Native
German Deutsch
French français
Spanish español
Portuguese português

Suggest a Locale

To suggest a Locale for ParSec, please open an issue and use the "Locale" tag informing us of the locale you wish to add

Usage

ParSec

Importing the module:

const ParSec = require('parsec');

Getting started:

This module is a hybrid function-object, this means that the module can be called by running both:

let parsed = ParSec('1 minute, 30 seconds and 145 milliseconds');

And:

let parsed = ParSec.parse('1 minute, 30 seconds and 145 milliseconds');

Note: in both cases here, parsed is an instance of TimeConstruct.
TimeConstruct is a custom class built to provide detailed information about your parsed results.
Read the documentation on TimeConstruct for more information

Values:

self:

Parameters:
inputString: String

Description: Formats the provided string into an instance of TimeConstruct.

Usage:

ParSec(<inputString>)

format:

Parameters
inputString: String

Description:
Formats the provided string using internal values (Internal version of ParSec(string))

parse:

Parameters
inputString: String

Description:
Formats the provided string into an instance of TimeConstruct (Internal version of ParSec(string))


TimeConstruct

Layout:

Values:

locale: String
milliseconds: Number
seconds: Number
minutes: Number
hours: Number
days: Number
weeks: Number
months: Number
years: Number

Methods:

format:

Parameters
inputString: String

Description:
Formats the provided string using internal values (Internal version of ParSec(string))

into:

Parameters
inputString: String

Description:
Formats the provided string, converting all internal values to the largest specified value (Internal version of ParSec(string))

More coming soon....

Readme

Keywords

none

Package Sidebar

Install

npm i parsec

Weekly Downloads

376

Version

2.0.2

License

ISC

Unpacked Size

19.6 kB

Total Files

15

Last publish

Collaborators

  • npm