| 1 | # no code | ||
| 2 | ## no critic: TestingAndDebugging::RequireUseStrict | ||
| 3 | package Acme::CPANModules::Parse::HumanDate; | ||
| 4 | |||
| 5 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 6 | 1 | our $DATE = '2021-09-11'; # DATE | |
| 7 | 1 | our $DIST = 'Acme-CPANModules-Parse-HumanDate'; # DIST | |
| 8 | 1 | our $VERSION = '0.001'; # VERSION | |
| 9 | |||
| 10 | 1 | our $LIST = { | |
| 11 | summary => "Modules that parse human date/time expression", | ||
| 12 | entries => [ | ||
| 13 | { | ||
| 14 | module=>'DateTime::Format::Natural', | ||
| 15 | description => <<'_', | ||
| 16 | |||
| 17 | Compared to <pm:DateTime::Format::Flexible>, this module can also parse | ||
| 18 | duration in addition to date/time, e.g.: | ||
| 19 | |||
| 20 | 2 years 3 months | ||
| 21 | |||
| 22 | And it also can extract the date expression from a longer string. | ||
| 23 | |||
| 24 | Speed-wise, I'd say the two modules are roughly comparable. For some patterns | ||
| 25 | one might be faster than the other. | ||
| 26 | |||
| 27 | _ | ||
| 28 | bench_code_template => 'DateTime::Format::Natural->new->parse_datetime(<str>)', | ||
| 29 | }, | ||
| 30 | { | ||
| 31 | module=>'DateTime::Format::Flexible', | ||
| 32 | description => <<'_', | ||
| 33 | |||
| 34 | One advantage of this over <pm:DateTime::Format::Natural> is its time zone | ||
| 35 | support, e.g.: | ||
| 36 | |||
| 37 | yesterday 8pm UTC | ||
| 38 | yesterday 20:00 +0800 | ||
| 39 | yesterday 20:00 Asia/Jakarta | ||
| 40 | |||
| 41 | Speed-wise, I'd say the two modules are roughly comparable. For some patterns | ||
| 42 | one might be faster than the other. | ||
| 43 | |||
| 44 | _ | ||
| 45 | bench_code_template => 'DateTime::Format::Flexible->new->parse_datetime(<str>)', | ||
| 46 | }, | ||
| 47 | |||
| 48 | { | ||
| 49 | module => 'Date::Parse', | ||
| 50 | description => <<'_', | ||
| 51 | |||
| 52 | This module can parse several formats, but does not really fall into "human | ||
| 53 | date/time parser" as it lacks support for casual expression like "yesterday" or | ||
| 54 | 3 hours ago". | ||
| 55 | |||
| 56 | _ | ||
| 57 | }, | ||
| 58 | ], | ||
| 59 | |||
| 60 | bench_datasets => [ | ||
| 61 | {args=>{str => 'yesterday'}}, | ||
| 62 | {args=>{str => '2 days ago'}}, | ||
| 63 | {args=>{str => '2021-09-06 20:03:00'}}, | ||
| 64 | ], | ||
| 65 | }; | ||
| 66 | |||
| 67 | 1 | 1; | |
| 68 | # ABSTRACT: Modules that parse human date/time expression | ||
| 69 | |||
| 70 | __END__ |