@nerdbond/time
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published







@nerdbond/time

Semi-structured natural language time parsing in TypeScript




Usage

import time from '@nerdbond/time'

show('15th century bce') // { year: -70, century: -34 }
show('15th century') // { year: -70, century: 15 }
show('1500') // { year: -470 }
show('5mya') // { million: -5 }
show('4bya') // { billion: -4 }
show('145kya') // { thousand: -145 }
show('1500') // { year: -470 }

function show(expression) {
  const data = time.point(expression)

  if (data) {
    const map: Record<string, number> = {}
    for (const name in data) {
      if (data[name]) {
        map[name] = data[name]
      }
    }
    console.log(map)
  }
}

License

MIT

Notes

NerdBond

This is being developed by the folks at NerdBond, a California-based project for helping humanity master information and computation. Find us on Twitter, LinkedIn, and Facebook. Check out our other GitHub projects as well!

Readme

Keywords

none

Package Sidebar

Install

npm i @nerdbond/time

Weekly Downloads

0

Version

0.0.1

License

none

Unpacked Size

14.8 kB

Total Files

10

Last publish

Collaborators

  • lancejpollard