Skip to content

Commit 6dc175a

Browse files
committed
always use DateTime::Format::ISO8601 for parsing dates from API
We're already using DateTime::Format::ISO8601 to parse dates in some cases, so just use it consistently, removing the need for Regexp::Common::time.
1 parent 906d250 commit 6dc175a

File tree

4 files changed

+8
-84
lines changed

4 files changed

+8
-84
lines changed

cpanfile

-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ requires 'Plack::Middleware::Session::Cookie';
7070
requires 'Plack::Session';
7171
requires 'Plack::Test';
7272
requires 'Ref::Util', '>= 0.008';
73-
requires 'Regexp::Common';
74-
requires 'Regexp::Common::time';
7573
requires 'Starman', '>= 0.4008';
7674
requires 'Template::Alloy', '== 1.020';
7775
requires 'Term::Size::Any';

cpanfile.snapshot

-68
Original file line numberDiff line numberDiff line change
@@ -2740,20 +2740,6 @@ DISTRIBUTIONS
27402740
perl 5.008001
27412741
strict 0
27422742
warnings 0
2743-
Modern-Perl-1.20200211
2744-
pathname: C/CH/CHROMATIC/Modern-Perl-1.20200211.tar.gz
2745-
provides:
2746-
Modern::Perl 1.20200211
2747-
odern::Perl 1.20200211
2748-
requirements:
2749-
ExtUtils::MakeMaker 0
2750-
IO::File 0
2751-
IO::Handle 0
2752-
feature 0
2753-
mro 0
2754-
perl 5.010
2755-
strict 0
2756-
warnings 0
27572743
Module-Build-0.4231
27582744
pathname: L/LE/LEONT/Module-Build-0.4231.tar.gz
27592745
provides:
@@ -4853,60 +4839,6 @@ DISTRIBUTIONS
48534839
ExtUtils::MakeMaker 0
48544840
XSLoader 0
48554841
perl 5.006
4856-
Regexp-Common-2017060201
4857-
pathname: A/AB/ABIGAIL/Regexp-Common-2017060201.tar.gz
4858-
provides:
4859-
Regexp::Common 2017060201
4860-
Regexp::Common::CC 2017060201
4861-
Regexp::Common::Entry 2017060201
4862-
Regexp::Common::SEN 2017060201
4863-
Regexp::Common::URI 2017060201
4864-
Regexp::Common::URI::RFC1035 2017060201
4865-
Regexp::Common::URI::RFC1738 2017060201
4866-
Regexp::Common::URI::RFC1808 2017060201
4867-
Regexp::Common::URI::RFC2384 2017060201
4868-
Regexp::Common::URI::RFC2396 2017060201
4869-
Regexp::Common::URI::RFC2806 2017060201
4870-
Regexp::Common::URI::fax 2017060201
4871-
Regexp::Common::URI::file 2017060201
4872-
Regexp::Common::URI::ftp 2017060201
4873-
Regexp::Common::URI::gopher 2017060201
4874-
Regexp::Common::URI::http 2017060201
4875-
Regexp::Common::URI::news 2017060201
4876-
Regexp::Common::URI::pop 2017060201
4877-
Regexp::Common::URI::prospero 2017060201
4878-
Regexp::Common::URI::tel 2017060201
4879-
Regexp::Common::URI::telnet 2017060201
4880-
Regexp::Common::URI::tv 2017060201
4881-
Regexp::Common::URI::wais 2017060201
4882-
Regexp::Common::_support 2017060201
4883-
Regexp::Common::balanced 2017060201
4884-
Regexp::Common::comment 2017060201
4885-
Regexp::Common::delimited 2017060201
4886-
Regexp::Common::lingua 2017060201
4887-
Regexp::Common::list 2017060201
4888-
Regexp::Common::net 2017060201
4889-
Regexp::Common::number 2017060201
4890-
Regexp::Common::profanity 2017060201
4891-
Regexp::Common::whitespace 2017060201
4892-
Regexp::Common::zip 2017060201
4893-
requirements:
4894-
Config 0
4895-
ExtUtils::MakeMaker 0
4896-
perl 5.01
4897-
strict 0
4898-
vars 0
4899-
warnings 0
4900-
Regexp-Common-time-0.16
4901-
pathname: M/MA/MANWAR/Regexp-Common-time-0.16.tar.gz
4902-
provides:
4903-
Regexp::Common::time 0.16
4904-
requirements:
4905-
ExtUtils::MakeMaker 0
4906-
Modern::Perl 0
4907-
Regexp::Common 0
4908-
Test::More 0.40
4909-
perl 5.006
49104842
Role-Tiny-2.002004
49114843
pathname: H/HA/HAARG/Role-Tiny-2.002004.tar.gz
49124844
provides:

lib/MetaCPAN/Web/Role/Response.pm

+8-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package MetaCPAN::Web::Role::Response;
22

33
use Moose::Role;
44
use DateTime::Format::HTTP;
5-
use Regexp::Common qw(time);
5+
use DateTime::Format::ISO8601 ();
66

77
=head2 last_modified
88
@@ -14,20 +14,15 @@ an ISO8601 formatted date string.
1414

1515
sub last_modified {
1616
my ( $self, $date ) = @_;
17-
if ( $date =~ /^\d+$/ ) {
17+
if ( ref $date ) {
18+
19+
# assume it's a DateTime
20+
}
21+
elsif ( $date =~ /^\d+$/ ) {
1822
$date = DateTime->from_epoch( epoch => $date );
1923
}
20-
elsif ( $date =~ /$RE{time}{iso}{-keep}/ ) {
21-
$date = eval {
22-
DateTime->new(
23-
year => $2,
24-
month => $3,
25-
day => $4,
26-
hour => $5,
27-
minute => $6,
28-
second => $7,
29-
);
30-
};
24+
else {
25+
$date = DateTime::Format::ISO8601->parse_datetime($date);
3126
}
3227
return unless ( eval { $date->isa('DateTime') } );
3328
$self->header(

lib/MetaCPAN/Web/View/HTML.pm

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use List::Util ();
1111
use Cpanel::JSON::XS ();
1212
use Gravatar::URL ();
1313
use MetaCPAN::Web::RenderUtil qw( filter_html );
14-
use Regexp::Common qw(time);
1514
use Number::Format ();
1615
use Text::MultiMarkdown ();
1716
use Text::Pluralize ();

0 commit comments

Comments
 (0)