2.0.2 • Published 4 years ago

parsec v2.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

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.

LanguageNative
GermanDeutsch
Frenchfrançais
Spanishespañol
Portugueseportuguê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....

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

7 years ago

1.5.3

8 years ago

1.5.2

8 years ago

1.5.1

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.1

8 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.3.0

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.0

9 years ago

0.0.1

11 years ago