
Extracts time from an arbitrary text input.
Features
- Deterministic and unambiguous time parsing.
Usage
import extractTime from 'extract-time';
extractTime('extracts time from anywhere within the input 14:00');
extractTime('extracts multiple times located anywhere within the input: 16:00, 18:00');
extractTime('distinguish between the civilian 1:30 PM ...');
extractTime('... and military time formats 13:30');
extractTime('resolves ambiguous times using the provided time notation bias 1:30', 12);
Signature
export type TimeNotationType = 12 | 24;
type TimeMatchType = {|
+time: string
|};
type extractTime = (
subject: string,
timeNotation: TimeNotationType,
) => $ReadOnlyArray<TimeMatchType>;
Related projects