Clausen Profit Systems, Inc.

Back to the Clausen Profit Systems home page.

Subject: Clausen Profit Systems TM Non-Y2K compliant 2400 dollar time clock!

Dear valued client,

What a year it has been for Clausen Profit Systems TM!  We have made
well over $0.00, and it has all been due to YOU, our valued client.

As a way of expressing our gratitude, we are giving away the Clausen
Profit Systems clock (attached).  This fantastic innovation displays
the time in 24 hundred dollar time *, AND as a special bonus, the
date as well!  But hurry!  This clock won't last! **

To use the clock, simply save dollar.c, and then at your Unix shell,
type: ***

	$ cc dollar.c -o dollar; ./dollar

And watch the fireworks!

Once again, thankyou for your support.
Your's sincerely,
Andrew Clausen
Managing Director

* The ammount indicated is the amount you owe Clausen Profit
Systems.  Remember: time IS money.

** It will cease to function properly at midnight, New Year's Eve as
it is not Y2K compliant.

*** If you're really enjoying it, try:

	$ su -c "cc dollar.c -o dollar; ./dollar"
	password: YOUR-ROOT-PASSWORD

dollar.c

#include 
#include 

#define MINUTE		60
#define HOUR		(MINUTE * 60)
#define DAY		(HOUR * 24)
#define YEAR		(DAY * 365)
#define LEAP_YEAR	(DAY * 366)

typedef struct {
	const char*	name;
	time_t		length;
	time_t		leap_length;
} Month;

Month
months[12] = {
	{"January",	31 * DAY, 0},
	{"February",	28 * DAY, DAY},
	{"March",	31 * DAY, 0},
	{"April",	30 * DAY, 0},
	{"May",		31 * DAY, 0},
	{"June",	30 * DAY, 0},
	{"July",	31 * DAY, 0},
	{"August",	31 * DAY, 0},
	{"September",	30 * DAY, 0},
	{"October",	31 * DAY, 0},
	{"November",	30 * DAY, 0},
	{"December",	31 * DAY, 0}
};

int
is_leap_year (int year)
{
	return (year % 4) == 0;
}

/* returns 2-digit year (19xx), to allow for more efficiency :-) */
int
get_year (time_t* remainder)
{
	time_t		t;		/* seconds since start of 1970 */
	time_t		year_length;
	int		year = 70;

	time (&t);

	while (1) {
		year_length = YEAR + is_leap_year (year) * DAY;
		if (t < year_length)
			break;
		t -= year_length;
		year++;
	}

	if (remainder)
		*remainder = t;

	return year;
}

int
get_month (time_t* remainder)
{
	time_t		t;
	time_t		month_length;
	int		year = get_year (&t);
	int		leap_year = is_leap_year (year);
	int		month;

	for (month = 0; month < 12; month++) {
		month_length = months [month].length
				+ leap_year * months [month].leap_length;
		if (t < month_length) 
			break;
		t -= month_length;
	}

	if (remainder)
		*remainder = t;
	return month;
}

int
get_day (time_t* remainder)
{
	time_t		t;
	int		day;

	get_month (&t);
	day = 1 + t / DAY;

	if (remainder)
		*remainder = t - (day - 1) * DAY;
	
	return day;
}

int
get_hour (time_t* remainder)
{
	time_t		t;
	int		hour;

	get_day (&t);
	hour = 1 + t / HOUR;

	if (remainder)
		*remainder = t - (hour - 1) * HOUR;

	return hour;
}

int
get_minute (time_t* remainder)
{
	time_t		t;
	int		minute;

	get_hour (&t);
	minute = 1 + t / MINUTE;

	if (remainder)
		*remainder = t - (minute - 1) * MINUTE;

	return minute;
}

int
main (int argc, char* argv[])
{
	while (1) {
		printf ("$%02d%02d.00, %d %s 19%02d on the Clausen dollar clock\n",
			get_hour (NULL),
			get_minute (NULL),
			get_day (NULL),
			months [get_month (NULL)].name,
			get_year (NULL));
		sleep (60);
	}
}

Back to the Clausen Profit Systems home page.