Permalink
Browse files

Use Date::Manip instead of Time::ParseDate

Revert back to using Date::Manip::Date instead of Time::ParseDate
for MoonPhase, like the original Catalyst model, as the latter module
doesn't not install on Windows (it complains about missing POSIX::tzset
in Strawberry Perl.)
  • Loading branch information...
1 parent e5d3532 commit 1671455192064d9461a09e8892e7cdcc99db2103 @zakame committed Aug 28, 2011
Showing with 13 additions and 9 deletions.
  1. +1 −1 Makefile.PL
  2. +1 −1 README.org
  3. +6 −4 lib/Model/MoonPhase.pm
  4. +4 −2 t/model/moonphase.t
  5. +1 −1 templates/example/mojoten-index.html.ep
View
2 Makefile.PL
@@ -14,7 +14,7 @@ WriteMakefile(
'Mojolicious' => '1.80',
'Modern::Perl' => 0,
'Astro::MoonPhase' => 0,
- 'Time::ParseDate' => 0,
+ 'Date::Manip ' => 0,
'Try::Tiny' => 0
},
test => {TESTS => 't/*.t'}
View
2 README.org
@@ -53,7 +53,7 @@ JavaScript to render them properly on a page.
*** DONE [[http://localhost:3000/moonphase][MoonPhase]]: show phase-of-moon and illumination
Another simple model, also non-OO, but uses additional code from
-Astro::MoonPhase and Time::ParseDate. Again, app is different from the
+Astro::MoonPhase and Date::Manip. Again, app is different from the
original by emitting in JSON to be read by JavaScript filling a section
of the page, as well as being able to handle bad input correctly (by
bailing out in case of bad input via Try::Tiny.) Still needs test
View
10 lib/Model/MoonPhase.pm
@@ -1,18 +1,20 @@
package Model::MoonPhase;
use Modern::Perl;
use Astro::MoonPhase;
-use Time::ParseDate;
+use Date::Manip::Date;
use Carp;
use Exporter 'import';
our @EXPORT_OK = qw(illumination is_waxing);
+my $date = Date::Manip::Date->new;
+
sub moonphase {
my $raw_timish = shift;
- my ($time, $error) = parsedate($raw_timish);
- croak "Bad time: '$raw_timish' is not a recognized date/time" if $error;
- return phase($time);
+ my $err = $date->parse($raw_timish);
+ croak "Bad time: '$raw_timish' is not a recognized date/time" if $err;
+ return phase($date->secs_since_1970_GMT);
}
sub illumination { [moonphase(shift)]->[1] }
View
6 t/model/moonphase.t
@@ -1,18 +1,20 @@
#!/usr/bin/env perl
use Modern::Perl;
use Astro::MoonPhase;
-use Time::ParseDate;
+use Date::Manip::Date;
use Test::More tests => 5;
BEGIN {
use_ok('Model::MoonPhase', qw(illumination is_waxing))
or BAIL_OUT "Can't see the moon in cloudy skies";
}
+my $date = Date::Manip::Date->new;
my $time = "42 days ago at 5pm";
+$date->parse($time);
is_deeply(
[Model::MoonPhase::moonphase($time)],
- [phase(parsedate($time))],
+ [phase($date->secs_since_1970_GMT)],
"correct moon phase"
);
View
2 templates/example/mojoten-index.html.ep
@@ -37,7 +37,7 @@
<p>Show phase-of-moon and illumination</p>
</header>
<p>Another simple model, also non-OO, but uses additional code
- from Astro::MoonPhase and Time::ParseDate. Again, app is
+ from Astro::MoonPhase and Date::Manip. Again, app is
different from the original by emitting in JSON to be read by
JavaScript filling a section of the page, as well as being able
to handle bad input correctly (by bailing out in case of bad

0 comments on commit 1671455

Please sign in to comment.