Hi Cyrus,

I don't know if this would interest you or not, but I've ported a C program to a perl script that computes the date according to the Tranquility calendar (centered on the first moon landing). I've been wanting to port this to DateTime, but it's got some unique features like 13 months and 1 or 2 null days per year. The Hebrew calendar module for DateTime also has 13 months, and I was looking at that as a possible model to build upon, but it's messy. I can't recall if they have any calendars that have null days, however.

Anyway, here's the script. If nothing else, I hope you find it entertaining.

Cheers,
Troy

#!/usr/bin/perl 
# This product includes software developed by Scott M Harrison (mailto://[EMAIL PROTECTED]).
# Ported to perl by Troy Davis (mailto://[EMAIL PROTECTED])

use strict;
use Switch;
use Time::Local;
use Data::Dumper;

print tranquility_date() . "\n";
exit();


sub tranquility_date() {
	my ($dayOfYear, $yearOfCommonEra) = @_;
	my $show_date = 0;
	my ($second,$minute,$hour,$dayOfMonth,$month,$dayOfWeek);
	if (($dayOfYear =! /^\d+/) && ($dayOfYear > 0)  && ($dayOfYear < 367) && ($yearOfCommonEra =~ /^(-{1})*\d+$/)) {
		# Values passed in look legit
	} else {
		# Assume now in UTC time zone
		$ENV{TZ} = ':/usr/share/zoneinfo/UTC'; 
		($second,$minute,$hour,$dayOfMonth,$month,$yearOfCommonEra,$dayOfWeek,$dayOfYear) = localtime();
		$dayOfYear++;
		$yearOfCommonEra += 1900;
		$show_date = 1;
	}

	my @daysOfWeek = ( "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" );
	my @months = ( "Archimedes", "Brahe", "Copernicus", "Darwin", "Einstein", "Faraday", "Galileo", "Hippocrates", "Imhotep", "Jung", "Kepler", "Lavoisier", "Mendel" );
	my $daysInNonLeapYear = 365;
	my $daysInTranquilityMonth = 28;
	my $aldrinDay = 60;
	my $armstrongDay = 201;
	my $yearOfTranquility = 1969;
	my $isLeapYear = ((($yearOfCommonEra % 4) == 0) && (($yearOfCommonEra % 400) != 100) && (($yearOfCommonEra % 400) != 200) && (($yearOfCommonEra % 400) != 300));
	my $tranquilityDayOfYear = 0;
	my $specialDay = 0;
	my $day = 0;
	my $month = 1;
	my $year;
	my $afterArmstrongDay = $dayOfYear > $armstrongDay;

	if ($isLeapYear) {
		if ($dayOfYear > $aldrinDay) {
			$dayOfYear--;
		}
		elsif ($dayOfYear == $aldrinDay) {
			$specialDay = 1;
		}
	}
	if ($dayOfYear == $armstrongDay) {
		$specialDay = 2;
	}

	$tranquilityDayOfYear = $dayOfYear - $armstrongDay + ($afterArmstrongDay ? 0 : $daysInNonLeapYear);
	
	if ($specialDay == 0) {
		$month = sprintf("%d", ($tranquilityDayOfYear - 1) / $daysInTranquilityMonth);
		$day = $tranquilityDayOfYear - $month * $daysInTranquilityMonth;
	}
	elsif (($yearOfCommonEra == $yearOfTranquility) && ($specialDay == 2)) {
		$specialDay = 3;
	}

	$year = $yearOfCommonEra - $yearOfTranquility + ($afterArmstrongDay ? 1 : 0);
	if ($year <= 0) { $year--; }
	
	my $out = '';
	
	switch ($specialDay) {
		case 0 { $out .= $daysOfWeek[$day % 7] . ', ' . $months[$month] . " " . $day . ","; next }
		case 1 { $out .= "Aldrin Day $year"; next }
		case 2 { $out .= "Armstrong Day $year"; next }
		case 3 { $out .= "Moon Landing Day"; }
		}
	if (3 != $specialDay) {
		$out .= sprintf(" %d", abs($year));
		if ($year < 0) { $out .= " BT"; }
	}
	if ($show_date) {
		$out .= " " . sprintf("%02d", $hour) . ':' . sprintf("%02d", $minute) . ':' . sprintf("%02d", $second) . " UTC";
	}
	return $out;
}





On May 15, 2008, at 12:31 PM, Cyrus Noble wrote:

I am new to the DateTime project, and I am interested in helping with a
calender.

I can't easily locate a TODO list; however, are any of the calenders
open for work?  How about Hindu or Islamic?



Reply via email to