0.0.15 • Published 4 months ago

yearrange v0.0.15

Weekly downloads
5
License
MIT
Repository
github
Last release
4 months ago

Node.js Year Range Parser

A Node.js library for parsing year range strings and converting them into usable dates. This library is only designed to handle year ranges (all month/day information is discarded).

Its usage is best explained through some examples:

var yr = require("yearrange");

yr.parse("1877")
// {"start": 1877, "end": 1877}

yr.parse("1847-48")
// {"start": 1847, "end": 1848}

yr.parse("ca. 1810-20s")
// {"start": 1810, "end": 1829, "circa": true}

yr.parse("18th–19th century")
// {"start": 1700, "end": 1899}

yr.parse("Meiji era")
// {"start": 1868, "end": 1912}

Many more examples can be found in the test/date-tests.json file.

This library was originally built for parsing dates from museums, universities, galleries, and dealers for Ukiyo-e.org by John Resig.

API

In essence there is only a single generally-useful method exposed:

parse(dateString)

This method takes in a single argument: A string holding the year range. The method returns an object representing the date range.

For example an object after calling parse("1877") might look like:

{"original":"1877","start":1877,"end":1877}

If no valid date is matched by the parser then undefined is returned instead.

License

The library is released under an MIT license.

0.0.14

4 months ago

0.0.15

4 months ago

0.0.13

5 months ago

0.0.11

5 months ago

0.0.12

5 months ago

0.0.10

5 months ago

0.0.9

5 months ago

0.0.8

5 months ago

0.0.7

5 months ago

0.0.6

6 months ago

0.0.5

8 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago