time-input-formatter
Interpret and format a user inputted time string or partial time string to 12hr or 24hr time
This library contains es5 and es6 implementations in the deliverable and is fully tree-shakable for es6.
Version: 1.0.0
deriveTimeFormat
Derive a time format from a user inputted string
Since v1.0.0
Param | Type |
---|---|
value The input value to derive the format |
string |
format The desired output format |
Format |
Returns: {ParsedTime}
Supporting Types
export type Format = '12hm' | '12hms' | '24hm' | '24hms';
export type ParsedTime = { valid: boolean, value: string };
Import
import { deriveTimeFormat, Format, ParsedTime } from 'time-input-formatter';
Input | 12hm Output | 12hms Output | 24hm Output | 24hms Output |
---|---|---|---|---|
7 |
7:00 AM |
7:00:00 AM |
07:00 |
07:00:00 |
7a |
7:00 AM |
7:00:00 AM |
07:00 |
07:00:00 |
7am |
7:00 AM |
7:00:00 AM |
07:00 |
07:00:00 |
7p |
7:00 PM |
7:00:00 PM |
19:00 |
19:00:00 |
700 |
7:00 AM |
7:00:00 AM |
07:00 |
07:00:00 |
0700 |
7:00 AM |
7:00:00 AM |
07:00 |
07:00:00 |
715 |
7:15 AM |
7:15:00 AM |
07:15 |
07:15:00 |
71527 |
7:15 AM |
7:15:27 AM |
07:15 |
07:15:27 |
16 |
4:00 PM |
4:00:00 PM |
16:00 |
16:00:00 |
0 |
12:00 AM |
12:00:00 AM |
00:00 |
00:00:00 |
27 |
12:00 AM |
12:00:00 AM |
00:00 |
00:00:00 |
License
MIT
Michael Paravano Author
Dependencies
@paravano/utils | ^1.4.0 |
date-fns | ^2.21.1 |