#!/usr/local/bin/perl -w

# Check the shebang line and then just call this script from your .profile

use strict;
use DateTime;
use Text::Wrap;

$Text::Wrap::columns = 80; # or whatever your console likes
# or else, read recipe 1.17 from Perl Cookbook (2d ed)

my $dg = DateTime->now;
print "\nGregorian calendar\n";
print $dg->iso8601, $dg->strftime(", %A %d %B %Y%n");
print "JD : ", $dg->jd, " MJD : ", $dg->mjd, "\n";

eval 'use DateTime::Calendar::Julian';
unless ($@) {
  my $d = DateTime::Calendar::Julian->now;
  print "\nJulian calendar\n";
  print $d->iso8601, $d->strftime(", %A %d %B %Y%n");
}

eval 'use DateTime::Calendar::Mayan';
unless ($@) {
  my $d = DateTime::Calendar::Mayan->now;
  print "\nMayan calendar\n";
  print $d->bktuk, " (baktun, katun, tun, uinal, kin)\n";
}

eval 'use DateTime::Calendar::FrenchRevolutionary';
unless ($@) {
  my $dr = DateTime::Calendar::FrenchRevolutionary->now;
  print "\nFrench Revolution\n";
  print $dr->iso8601, $dr->strftime(", %A %d %B %EY, %Ej%n"); # in French
  (my $text = fill('', '', $dr->on_date('en'))) =~ s/\n\n+/\n/g;
  print $text;                                                # in English
}

eval 'use DateTime::Calendar::Pataphysical';
unless ($@) {
  my $d = DateTime::Calendar::Pataphysical->now;
  print "\n'Pataphysique\n";
  print $d->ymd, $d->strftime(", %A %d %B %Y %*%n");
}

eval 'use DateTime::Format::Roman';
unless ($@) {
  my $conv = DateTime::Format::Roman->new(pattern => "%OD %b %y\n");
  print "Calendrier romain : ", $conv->format_datetime($dg);
}

eval 'use Date::Discordian';
unless ($@) {
  print discordian(time()), "\n";
}

eval 'use DateTime::Fiction::JRRTolkien::Shire';
unless ($@) {
      my $h = DateTime::Fiction::JRRTolkien::Shire->from_object(object => $dg);
      print "Shire : ", $h->on_date();
}
