Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tjenkinson/human-string-to-date-time
A library that parses a human representation of a UK English formatted date/time into an object.
https://github.com/tjenkinson/human-string-to-date-time
date datetime human humanreadable parser time
Last synced: 8 days ago
JSON representation
A library that parses a human representation of a UK English formatted date/time into an object.
- Host: GitHub
- URL: https://github.com/tjenkinson/human-string-to-date-time
- Owner: tjenkinson
- License: mit
- Created: 2023-02-11T12:33:38.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-12T22:49:56.000Z (7 months ago)
- Last Synced: 2024-04-14T10:00:59.542Z (7 months ago)
- Topics: date, datetime, human, humanreadable, parser, time
- Language: TypeScript
- Homepage:
- Size: 813 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Human String To Date/Time
A library that parses a human representation of a UK English formatted date/time into an object.
It will always return the object with bits that are unkown are set to `null`.
## Example Inputs
- `1st December`
- `December 1st`
- `December 1`
- `1 Dec`
- `Dec 1993`
- `Dec 1993`
- `01/12`
- `01-12`
- `01.12`
- `01.12.93`
- `01.12.1993`
- `01.12.1993`
- `1pm`
- `1:12pm`
- `13:12`
- `13:12:10`
- `13:12:10.300`
- `quarter to 12`
- `Wednesday 16th`
- `Thursday`
- `Sat`
- `12th November 1995 at quarter past 2`## Usage
```ts
import { parse } from 'human-string-to-date-time';console.log(parse('12th November 1995 at quarter past 2'));
```outputs
```js
{
dayOfWeek: 0,
day: 11,
month: 10,
year: 1995,
hour: 2,
minute: 15,
second: null,
millisecond: null,
wasTwelveHourFormat: true
}
```## Bugs
If you have a string that you believe should be parseable but is not working please [open an issue](https://github.com/tjenkinson/human-string-to-date-time/issues/new).