README
Parsers
A Library of string to data-type formatters
Build
Run npm run build
to build the project. The build artifacts will be stored in the dist/
directory.
Running unit tests
Run npm run test
to execute the unit tests via Jest.
Parsers
parseDate takes an "any" and an optional culture string (defaults to en-US). Returns a date object
- The input can be a formatted date like 12/31/2020
- The input can be a formatted date like 12-31-2020
- The input can be an unformatted date like 12312020 or 123120
- If the input is already a Date object, it'll return that object.
- If the input is neither a string or a Date object, it'll return a null
parseISODate takes an "any" and returns a date object
- If the input is null, the output will be null
- If the input can't be parsed to a valid date, the output will be null
parseNumber takes an "any" and an optional culture string (defaults to en-US). Returns a number
- The input will be parsed using the culture passed in.
- If the input is null, the output will be null
- If the input can't be parsed to a valid number, the output will be null