Skip to content

nilbuild/timelang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timelang

Packages to work with natural language time expressions.

License: MIT Docs

Package What it does? Version
@timelang/parse Parse natural language time expressions into dates, times, and ranges npm version
@timelang/suggest Autocomplete suggestions for time expressions npm version

@timelang/parse

npm install @timelang/parse
import { parse, parseDate, parseDuration, parseSpan, scan } from '@timelang/parse';

parseDate('next friday at 3pm');        // Date
parseDuration('2h 30m');                // 9000000 (milliseconds)
parseSpan('jan 5 to jan 20');           // { start: Date, end: Date, duration: number }

parse('Team Sync - next monday');       // { type: 'date', date, title: 'Team Sync' }
parse('mid Q1');                        // { type: 'fuzzy', start, end, approximate: true }

scan("let's meet next monday at 530pm");
// [{ result: {...}, match: 'next monday at 530pm', start: 11, end: 31 }]

For full API reference and examples, visit timelang.dev.

@timelang/suggest

npm install @timelang/suggest
import { suggest, suggestTime } from '@timelang/suggest';

suggest('tom');
// [
//   { label: 'tomorrow at 9am', date: Date },
//   { label: 'tomorrow at 2pm', date: Date },
//   ...
// ]

suggestTime('9');
// [
//   { label: '09:00 am', hour: 9, minute: 0, period: 'am' },
//   { label: '09:00 pm', hour: 9, minute: 0, period: 'pm' },
//   ...
// ]

For full API reference and examples, visit timelang.dev/suggest.

License

MIT

About

Parse natural language time expressions into dates, durations, and ranges.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors