Extracts time from an arbitrary text input.
OTHER License
Extracts time from an arbitrary text input.
import extractTime from 'extract-time';
extractTime('extracts time from anywhere within the input 14:00');
// [{time: '14:00'}]
extractTime('extracts multiple times located anywhere within the input: 16:00, 18:00');
// [{time: '16:00'}, {time: '18:00'}]
extractTime('distinguish between the civilian 1:30 PM ...');
// [{time: '13:30'}]
extractTime('... and military time formats 13:30');
// [{time: '13:30'}]
extractTime('resolves ambiguous times using the provided time notation bias 1:30', 12);
// [{time: '13:30'}]
/**
* Indicates if time format is 12-hour or 24-hour clock notation.
*/
export type TimeNotationType = 12 | 24;
/**
* @property time 24-hour military time.
*/
type TimeMatchType = {|
+time: string
|};
/**
* @param subject Arbitrary text input.
*/
type extractTime = (
subject: string,
timeNotation: TimeNotationType,
) => $ReadOnlyArray<TimeMatchType>;
extract-date
Extracts date from an arbitrary text input.extract-price
Extracts price from an arbitrary text input.