Plugin for parsing Polish dates from Facebook web page. It allows convert datest like:
- dziś o 02:51
- jutro o 02:51
- po jutrze o 02:51
- przedwczoraj o 04:39
- Wczoraj o 06:04
- 2 tygodnie temu
- 31 stycznia 2020
- 21 kwietnia o 16:07
- 28 marca
- 1 godz.
- 1 dni
- 59 min
- 51 sekund temu
To JSON format or directly to Date objects.
npm i fb-date-parser
Import parser:
import {parser} from 'fb-date-parser';
You can convert human version of date to JSON:
parser.toJson('Wczoraj o 06:04');
you will see
{year: 2021, month: 4, day: 7, hour: 6, minute: 4}
You can also get Date object:
parser.fromString('Wczoraj o 06:04');
you should get:
Wed Apr 07 2021 06:04:00 GMT+0200 (Central European Summer Time)
If you have date described as Wczoraj o 06:04
but scrapped at 2021-06-08T20:17:11.421Z
,
you can set relative date by the following code:
parser.setDate(new Date('2021-06-08T20:17:11.421Z'))
.fromString('Wczoraj o 06:04')
You will see new Date('2021-06-07T06:04')
This relative data will be saved until fromString
or toJson
will be used.
Then it is cleared. You can clear date by yourself using unsetDate()
.
Package is funded and maintained by company:
- JUPITER19 SPÓŁKA Z OGRANICZONĄ ODPOWIEDZIALNOŚCIĄ
- Added
51 sekund temu
- Added
dziś o 02:51
,jutro
,po jutrze
- Weeks abd a day before yesterday support
- Relative dates are not saved in parser state
- Consistent error handling
- Relative dates with years works better
- Months with polish characters fixed
- tscofig.json fixed (dist simplified)
- Dist content added to package
- Relative dates
- Simplified import
- Lib directory renamed to dist
- Non-breaking spaces handling (NBSP)
- CHANGELOG and documentation
- Test case for
31 stycznia 2020
- Pure JS version of library in
lib
directory - Method
fromString
that returns Date object
- Name of
attempt
changed totoJson
- Method
attempt
that prepareJSON
object representing date - Tests for cases
11 października 2018
21 kwietnia o 16:07
Wczoraj o 06:04
28 marca
1 godz.
1 dni
59 min