Voder-Vocoder

The Log of Hal Canary

Navigation: Home | THE LOG | Log Archives | Resume | Contact Info | Public Key | SSL | Math Applets | Site Map | WP Backend | RSS2 | Atom

Email2

== Email2 ==

Here’s a proposal for new e-mail protocols to completely replace existing SMTP/MIME/IMAP/POP protocols. There would be a phase-in period, lasting about 5-10 years, during which two systems would exist in paralel and servers would fall back to old protocols where the new ones aren’t availible yet.

The name of the new protocols would be Email2. It would contain the following protocols:

Email2 E-Mail Client Protocol
	* client-server connections
	* replaces SMTP, IMAP, POP
	* Specifies how the client sends and
	  recieves messages from the server.
	* Client configuration is simplified:
	  user ONLY specifies e-mail address
	  and password.  No seperate inbound
	  and outbound configurations.
	* Use of TLS strongly recommended.
Email2 E-Mail Server Protocol
	* server-server connections
	* replaces SMTP
	* meant to discourage spam
	* Use of TLS strongly recommended.
	* servers must verfy dns records of
	  sending server before accepting e-mail.
Email2 E-Mail File Format
	* replaces MIME
	* 8-bit
	* unicode (UTF-8) for all text,
	  including headers
	* mesage is compressed with DEFLATE
	  algorithm
Email2 E-Mail Storage Protocol
	* replaces maildir, mbox, et cetera
	* Can be used by all major OSes
	* similar to maildir
	* allows user to switch clients seamlessly

== Email2 E-Mail File Format ==

First of all, we need to get rid of 7-bit and linelength limitations that are part of SMTP.

The message is composed of three parts:

Head
Body
Attachments

Specifically, we would have the following:

Magic number representing this file format.
0x0a
UTF-8 data (the head) with each field
	seperated by a single unix-style endline.
0x0a0a (two endlines to specify the end of the head)
a gziped file containing the body
the attachemnts, somehow.

The head is similar to SMTP headers, but is encoded in UTF-8. There are more restrictions on what can be in the headers, for instance “From:” must be identical to the email sending the message, or it will not be accepted. Mailing lists have their own specific headers.

Since the body may be long and the server won’t need to read it (except for spam filtering), it will be compressed.

The body should *not* be HTML, since that introduces several security & spam risks. I suggest UTF-8 text with a minimal markup syntax to allow for “slightly rich” text. The text of the body may have long lines intended to be wrapped to whatever screen is availible. It is not assumed that this plain text is monospaced or wrapped at 70 characters.

All printable Unicode characters are acceptable in the body.

Because plain text is so unacceptable to most people, we allow text to be transformed to italics, bold, monospaced, subscript, superscript, strikethrough, and underline.

Whole paragraphs (seperated by newlines) can be modified with indention, center, and rightjustify.

The minimal markup syntax would use the “\” backslash character as an escape character. The following codes would be used for text modifications:

\{ec} = escape character, a literal "\"
\{bi} = begin italics
\{ei} = end italics
\{bb} = begin bold
\{eb} = end bold
\{bm} = begin monospaced
\{em} = end monospaced
\{bp} = begin subscriPt
\{ep} = end subscriPt
\{bt} = begin superscripT
\{et} = end superscripT
\{bs} = begin strikethrough
\{es} = end strikethrough
\{bu} = begin underline
\{eu} = end underline
\{bi} = begin indentation (this one *stacks*)
\{ei} = end indentation (only end one level)
\{cj} = begin center justification on this line
\{lj} = go back to left justification on this line
\{rj} = begin right justification on this line

The backslash character *must* be followed by one of those two-character escape codes to be a conforming document.

All conforming email clients should display this markup to the user in a consistant way and not expose the underlying escape characters.

Maformed escape syntax should always throw up an error. No conforming client can ever produce malfomerd syntax, so this might be spam.

Quoting previous email would always use the indentation markup, like a HTML blockquote element.

Additionally, whitespace characters like spaces, tabs, and newlines would be rendered just like they would in a plain-text document. One newline standard (such as CRLF or LF) would be chosen and all conforming clients would use it.
Tabs would be rendered in a consistant way—for example one could put a tab-stop every 8 ems. (1 em is the width of a single “m” glyph.) Or base the tabs off of the width of the client’s monospaced font.

Note that the following things are *banned* from this markup language: specifying fonts, specifying font types (other than monospace), specifying font size, specifying font color, specifying background color, blinking text, scrolling text, tables, embedded scripts, embedded images, or embedded documents. If you want any of that, you must attach an attachment.

Additionally, all conforming mail clinets *must* recognize IANA-registered URI schemes and make them into clickable (or otherwise selectable) links. But those links will look like URIs, to keep the process *transparent* to the user. URI’s can be imbedded in the text in the form “[whitespace]URI[whitespace]”, “(URI)”, “[URI]”, “{URI}”, or “<URI>”. This should be recognizable by the client since URIs generally do not contain whitespace characters or <[({})]>.

The header has none of this markup.

For the N attachemtns, the Internet media type, the preferred document name, whether it is compressed, a checksum or cryptographic hash, and file length is specified. For security purposes, the client mut not open these attachments automatically and should call a virus scanner before opening them. It is recommended that all email clients attempt to compress the attachements with DEFLATE before attaching them. If the compression results are good, then they will be attached like that. (For example, the ZIP file format can include files either compressed or uncompressed.) a checksum for each attachment would be included in the email file format. The exact format would be part of the standard, but I don’t have an opinion on how it should work.

== Email2 E-Mail Storage Protocol ==

The new standard would specify a standard way of storing email in a filesystem, similar to Maildir. This way, a user can *always* switch email clients seamlessly. Furthermore, a default place to store email would be used, specifed for each operating system. For example, under Windows it would be something like

	%HOMEDRIVE%%HOMEPATH%\Application Data\email\

and *NIX would use

	$HOME/.email/

== Email2 E-Mail Client Protocol & Server Protocol ==

Email2 is a Client-Server-Server-Client protocol. No more forwarding email through a chain of servers. No more faking addresses.

Suppose bannana@orange.com wants to email mango@plum.com.

Bannana’s client must connect to mail.orange.com directly, using a TLS encrypted session and verfying his creditions with a password (or optionally some other identifer, like a PKE key).

The connection is *not* SMTP, since we are throwing that protocol out the window. we’ll call it a “client-server” connection.

mail.orange.com verifies that the e-mail is well-formed and that the “From” address matches the address that Bannana used to log in with.

mail.orange.com then connects directly to mail.plum.com using a TLS-encrypted “server-server” connection and identifies itself as mail.orange.com. mail.plum.com *MUST* verify that mail.orange.com is who they say they are through checking (1) dns entries AND (2) TLS encryption keys. mail.orange.com has already verified mail.plum.com.

mail.orange.com then hands over the e-mail to mango@plum.com. Before terminating the session, mail.plum.com (1) checks to see that the e-mail is from an address at @orange.com (2) tells mail.orange.com whether there is a mango@ this address (3) checks to see if the message is well-formed. If not, then orange knows that the e-mail is undeliverable and will tell the sending client that. (There is an undeliverable folder on the server just for that purpose.)

Next, (this is an optional step that awesome mail servers will be able to do) mail.plum.com consults a series of rules that Mango specified earlier and sorts the mail into a subfolder of the Inbox folder. For example, if the subject contains a specific keyword, it might go in a subfolder for that keyword. The server might run Spamasasain on the message and sort it into a Inbox/Spam folder. Why does the server do this and not the client? Becasue whe user might use two clients on two different machines to connect to the server and doesn’t wat to repeat a bunch of rules!

Ideally, the rule format will be specified in the protocol.

Later, mango@plum.com creates a client-server connection with mail.plum.com This is a TLS-encrypted, fully authenticated connection. The first thing mango’s client does is check the Inbox folder and all it’s subfolders for new messages. It retrieves a few headers for each message (From, Subject, Date, Number of attachments, message length).

The client could be configured several different ways. If it is POP-style, it will immediately download all the messages and delete them off the server. If it is configured IMAP-style, it will leave messages on the server unless they are specifially deleted by ther user. It could also be configured mirror-style where it leaves a copy on the server but also mirrors each email lcoally. IMAP-style should be the default.

The user will see a heirarchy of folders:

plum.com/
	Inbox/
		Spam/
		Knitting_Circle/
	Old/
		Bannana/
		Apple/
		Nectarine/
	Sent/
	Undeliverable/
	Outbox/
	Drafts/
	Trash/
Local Folders/
	Drafts
	Outbox/
	Trash/
	Bannana/
	Apple/
	Nectarine/

The user could drag-and-drop the new email from Bannana from plum.com/Inbox/ to plum.com/Old/Bannana . This would be an atomic operation that the server could perform without copying the email, just moving some pointers around.

I am no human-interface guru, so this could probably use some refining.

The client also has a way of changing the delivery rules on the server in some standard way.

== Mailing Lists ===

Client-Server-Server-Server-Client Proticol would exist for mailing lists.

Suppose that bannana@orange.com wants to send a email to the Fruits mailing list, which has an email address of fruits%pear.com. mango@plum.com is on that list.

First of all, notice that mailing list addresses have a different syntax, replaceing the “@” with a “%”. the “%” is supposed to too like mutliple “@”s. [Is that going to be a problem with URI syntax? maybe we should use fruits#pear.com.]

For the first server-server connection, mail.orange.com connects to mail.pear.com, using the same authentication system. mail.pear.com then checks to see if there is a fruits mailing list and (this is important) if bannana@orange.com is authorized to email that list. mail.pear.com might be configured to reject anyone that is not on the list, or to reject anyone who isn’t a list owner, or to allow anyone to post to the list (which is a *BAD* idea).

mail.pear.com looks through the mailing list and sorts it by domain name, then connects sequentially all the domains to deliver the email. These connections are again authenticated both ways. When mango@plum.com gets the message it looks like this:

From: Bannana <bannana@orange.com>
To: Fruits <fruits%pear.com>
Delivered To: mango <mango@plum.com>

The “Delivered To” header was inserted by mail.plum.com (mail software are allowed to insert but not delete headers, but in general do less of this than the current generation of clients)

(*) A note about BCC (blind carbon copy). Assume that Bannana BCCed Mango on an email to Apple. Then Mango would see a header that says that.

From: Bannana <bannana@orange.com>
To: Apple <apple@pear.com>
BCC: mango <mango@plum.com>

If one BCC’s a mailing list then:

From: Bannana <bannana@orange.com>
To: Apple <apple@pear.com>
BCC: Fruits <fruits%pear.com>
Delivered To: mango <mango@plum.com>

is what Mango would see. Everyone on that list knows what list was BCCed. Apple, however, is in the dark.

There is no way to see who is on a mailing list unless you are an owner of that list. Of course the owner might make that information availible some other way.

== Timestamps ==

All timestamps in the email header should use ISO 8601 in the following way: 2007-12-21 17:47:01-05:00. Clients can convert to local timezone if they wish. Clients may diplay dates using local conventions as well.

There are multiple timestamps in the header

Date = when the client started to transmit
DateS = when the Sending server recieved the message
DateL = when the listsrev recieved the messafe
DateR = when the recieving server recieved the message
DateC = when the recieving client first noticed it

Client machines often have incorrect clocks. Servers are encouraged to use NTP to keep thier clocks up to date, so maybe a client could be configured to use DateS to timestamp the real message.

== Dead addresses ==

Since mail can no longer be forwarded, what happens when you get a new email address?

All email servers should keep a list of no-longer active email addresses and give an apropriate error code for undeliverable mail.

Delivery status:

Deliverable
Undeliverable - no such address
Undeliverable - account closed 

When a mail account is closed, the user or administrator can add a 1kb plain text (UTF-8) message explaining why it is closed and maybe another address to try.

This message should get back to the sender somehow, but not in the form of another email.

== Problems with this approach ==

A lot of coding. But most of it is really simple stuff.

Clients will need to be able to connect to both kinds of email servers for the interum.

Mail-sorting rules might be difficult to stadardize.

The standard needs to specify EVERYTHING, so that various implementations are fully compatable.

The NSA will find it much more difficlt to spy on your email. Servers could be designed with a wiretap mode where all emails to and from a particular address are automatically forwarded to the apropriate law enforcement.

It will be much simpler to fight spam: simply delete the offending dns entries.

This gives too much power to the DNS servers and the certificate authorities.

What about servers that aren’t connected to the internet 99+% of the time (most are)?

Hal Canary | Computers & Code | 2008-01-25 14:34:12 EST
Permanent Link | Comments Off

My XO-1 has gotten me interested in hacking in python again, since that is the XO’s primary programming environment.

I quickly hacked out an ftp script in python since the default install lacked an ftp client. “My next project will be to finally write version 1.0 of my fcp (FTP copy) program — a ftp client that uses rcp/scp syntax.

Here’s the first script:

#!/usr/bin/env python2.5
import ftplib
import os
import getpass
host="hostname"
user="hal"
pas=getpass.getpass(user+"@"+host+"'s password: ")
# local file with path
localfile="ftpcp"
# directory  on sever
dir="/www/pub"
# filrnaame on server
filename="ftpcp.txt"
# login to FTP
f=ftplib.FTP(host)
f.login(user, pas)
f.set_pasv(True)
f.cwd(dir)
f.storbinary("STOR " + filename, open(localfile, 'rb'))
f.quit()

Next I’ve got to write some very savy code that can parse complex command-line options.

Then I’ve got to learn how to do everything else in python.


Update: a function!

import ftplib
import os
import getpass
def ftpputfiles(host, direct, *files, **kwds):
    'user defaults to $USERNAME if blank'
    # does little error checking.  this is bad!
    user, password = ('', '')
    if kwds.has_key('user'):
        user = kwds['user']
    if user == '':
        user = os.environ['USERNAME']

    if kwds.has_key('password'):
        password = kwds['password']
    if password == '':
        querystring = '%s@%s's password: ' % (user,host)
        password = getpass.getpass(querystring)

    f = ftplib.FTP(host)
    f.login(user, password)
    f.set_pasv(True)
    f.cwd(direct)
    for localfile in files :
        filename = os.path.basename(localfile)
        fl = open(localfile, 'rb')
        f.storbinary('STOR %s' % filename, fl)
        fl.close()
    f.quit()

Hal Canary | Computers & Code | 2008-01-13 00:05:28 EST
Permanent Link | Comments Off

Downsample

I can’t tell the difference between a 32KBps and 224KBps mp3 file. Can you?

So I’m down-sampling all my mp3s to fit on my new mp3 player. I should be able to fit around 3 days of music onto my 1GB player this way.

Here’s a script to do that—a work in progress

#!/bin/sh

## Compressmp3s - Copyright 2007 Hal Canary
## Dedicated to the Public Domain.

## Arguments: a list of directories to search for mp3s
## This script will use lame to create a 32kbps version
## of those mp3 and save it in a subdirectory of $TARGETDIR

if [ "$#" -lt 1 ] ; then
    echo "Give me an argument!"
    exit 1
fi

TARGETDIR="$HOME/tmp/CompressedAudio"
mkdir -p "$TARGETDIR" || {
    echo "Use a directory you have permissions for.";
    exit 1 ; }

## for FILE in "$@" ; do
find "$@" -name '*.mp3' | while read FILE; do
    IN="$FILE"
    OUT="${TARGETDIR}/$FILE"
    ## Grab the id3 info for later use
    artist=`id3info "$IN" | grep TPE1 | \
        awk -F ': ' '{print $2}'`
    album=`id3info "$IN" | grep TALB | \
        awk -F ': ' '{print $2}'`
    track=`id3info "$IN" | grep TRCK | \
        awk -F ': ' '{print $2}'`
    song=`id3info "$IN" | grep TIT2 | \
        awk -F ': ' '{print $2}'`
    echo "$OUT"
    ## refuse to clobber a file
    if [ ! -f "$OUT" ] ; then
        echo "  artist=$artist"
        echo "  album=$album"
        echo "  track=$track"
        echo "  song=$song"
        echo ""
        DIRECTORY=`dirname "$OUT"`
        mkdir -p "$DIRECTORY" || { echo "permission error" ;
            exit 1 ; }
        lame -b 32 "$IN" "$OUT" \
            --ta "$artist" --tl "$album" \
            --tn "$track" --tt "$song" \
            --add-id3v2
    else
        echo "  already exists!"
    fi
done

Okay, on some files, I *can* tell the difference.

* * *

Compare: 032kbps mp3 versus 128kbps mp3.

Hal Canary | Computers & Code | 2007-12-12 12:40:06 EST
Permanent Link | Comments Off

12/05

Happy December 5th, everyone!

Hal Canary | Life | 2007-12-05 14:26:58 EST
Permanent Link | Comments Off

“King” *sounds* so much better than “President for Life”

If Pervez Musharraf had just declared himself King of Pakistan years back no one would have minded (except me; personally I hate kings (”mostly rapscallions”)). Do we ever ask the king of Saudi Arabia or queen of England to step down in favor of a democratically elected head of state?

Hal Canary | Politics | 2007-12-02 23:18:32 EST
Permanent Link | Comments Off

year in movies

Netflix keeps a record of what you’ve rented. That makes reviews easier:

===THE YEAR IN RENTAL DVDs 2007===

Hot Fuzz - loved it. May have to buy it at some point.

Stranger than Fiction - was okay. Don’t need to see it again.

Reign Over Me - liked it. Kind of depressing, but good.

Black Snake Moan - still can’t decide on this one. It may be a horrible movie, but I watched the whole thing.

300 - eh. Too full of itself.

Heroes: Season 1: Disc 1 - didn’t like it. Uninteresting characters. No narrative hook.

Harry Potter and the Goblet of Fire - not so good the second time through.

Howl’s Moving Castle - very good. Can’t believed I waited iuntil this year to watch it.

Who Killed the Electric Car? - I want an electric car.

Shopgirl - Eh. Clair Danes needs to play a new charater once in a while.

Charlie and the Chocolate Factory - don’t need to see this one twice. Was okay.

Children of Men - good movie. A little depressing.

MirrorMask - okay.

The Queen - okay.

Borat - awful. Had to send back mostly unwatched.

Running with Scissors - not that interesting.

Seven Years in Tibet - I liked it. Don’t need to see it again.

When the Levees Broke: A Requiem in Four Acts - well done. I recomend it. But don’t need to see it again.

Clerks 2 - unnessisary sequil.

The Adventures of Buckaroo Banzai - I can’t believe I hadn’t seen it before. Wonderful.

Talladega Nights: The Ballad of Ricky Bobby - Eh. Not that great.

The Island - I liked it. Good movie.

Hal Canary | Movies | 2007-12-02 23:17:39 EST
Permanent Link | Comments Off

new music player

My second-generation ipod died this year. It was five years old. I have now replaced it with a $40 1GB flash-based thing (an Insignia Kix from Best Buy). It has %10 of the memory, but is 10 times as easy to use. Just copy files onto it, no messing around with a separate program to create playlists and update databases.

Of course, next year they’ll have a 4GB product for the same price.

Hal Canary | Computers & Code | 2007-12-02 23:17:33 EST
Permanent Link | Comments Off

The obvious answer to our problems…

Was reading Gwyneth Cravens’ Power to Save the World: The Truth about Nuclear Energy (ISBN 9780307266569) and ran across a couple of interesting things.

Smokers are significantly more likely to absorb radon gas into their lungs than non-smokers. (Radon can be found in uranium mines, but can easily be flushed out with better ventilation.)

And I like this quote from Rip Anderson:

“A nuclear plant that emitted as much radiation as a coal-fired plant would be shut down.”

I’m still only 50 pages into the book. It’s a lot of basic science that I learned in high school, combined with a lot of facts I didn’t know, written by an author who started learning the subject from a state of total ignorance.

Hal Canary | What We Need More Of Is Science | 2007-11-25 16:13:36 EST
Permanent Link | Comments Off

SIG

A galactic system of measures used be several species to communicate with each other in a SF universe in my head. This is an explicitly _designed_ system of units. Base 16 is used because of the importance of binary. Aliens might find caesium-133 as easy to use as humans do. I don’t use multiples of the plank length—which might seem like the natural thing to do—because measuring the constant of gravitation accurately is harder than measuring the elementary charge, speed of light in vacuum, Planck’s constant, or Boltzmann’s constant. But my unit of electrical charge is sqrt(2)*16^15 times the Planck charge.

* * *

L = length unit = wavelength of radiation from the transition between hyperfine ground states of caesium-133 atoms at absolute zero, as that radiation passes through a perfect vacuum = 3.26122557 centimeters = 0.0326122557 meters. (The length unit is exactly 299792458/9192631770 meters.)

T = time unit = 16^8 * (Length unit / speed of light in a vacuum) = 0.467218464 seconds. Or the duration of 16^8 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium-133 atom at rest at a temperature of 0 K. (The time unit is exactly 4294967296/9192631770 seconds.)

M = unit of mass = 16^32 * Planck’s constant / (speed of light * length unit) = 0.0230618313 kg, which makes plank’s constant 16^-24. [I’m not sure of a nice way to state this definition.] (This unit is only as good as our measurement of Planck’s constant, currently with an uncertainty of around 5×10^-8. But we’re still arguing about how to define the kilogram.) [In the galaxy, the simplest way to realize this definition is to ask the most scientifically advanced species you can find to make a measurement of Planck’s constant with minimal uncertainty and manufacture a few 1-unit-of-mass artifacts.]

C = unit of current = 52.3615416 amperes. The Current Unit is a constant current which, if maintained in two straight parallel conductors of infinite length, of negligible circular cross section, and placed 1 Length Unit apart in a vacuum, would produce between these conductors a force per length equal to 1/(2*Pi) M*L/T^2/L.

E = unit of energy = M*L^2/T^2 = 0.000112360968 joules

P = unit of temPerature = 7.05881935 Kelvins, which makes Boltzmann’s constant 16^-16. One defines temperature in terms of the ideal-gas-law behavior of an ideal gas: the temperature of an ideal gas is defined to equal (16^16)(pressure)(volume)/(number of particles).

* * *

Therefore,

speed of light = 16^8 L/T (by definition)

Planck’s constant 16^-24 = M*L^2/T (by definition)

elementary charge = 16^-16 * sqrt(2 * the fine-structure constant) C*T (measured)

Newtonian constant of gravitation = 9.6853 × 10^-9 L^3/M/T^2 (measured)

electric constant = vacuum permittivity = 16^-16 T^4*C^2/L^3/M (by definition)

magnetic constant = vacuum permeability = 1 M*L/T^2/C^2 (by definition)

Boltzmann’s constant = 16^-16 M*L^2/T^2/P (by definition)

* * *

Hal Canary | Physics | 2007-11-04 19:55:24 EST
Permanent Link | Comments Off

number reform

Well, if we were really starting from scratch, I would go with a base 16 numbering system (already in use by programmers everywhere).

One would have to throw out SI units, which would cease to make sense. It would also give us an opportunity to throw out the base 360/60/60 system (degrees/minutes/seconds) and 24/60/60 (hours/minutes/seconds) that the Babylonians saddled us with.

The proposal: The sixteen digits 0123456789abcdef. Integers would be written

dd,dddd,dddd

with four digit groups (16 bits each). Mixed numbers would be witten

dd,dddd,dddd.ddd

and a decimal separating fractions. Floating-point numbers (or numbers in scientific notation) would always be written

d.dddPdd

or

d.dddP-dd

where “xPy” means “x × 16y” (P for exPonent.)

The new minute would be 1/256 th of an average day. (5.625 old-minutes) The new second would be 1/65536 th of a day (1.318 old-seconds).

The new standard length would be around 9.202 centimeters. that would make the speed of light equal to an even 16^8 (new standard lengths/new seconds)

The new degree would simply be 1/256th of a circle.

Translating to and from binary would of course be trivial.

One would have to come up with new prefixes which mean “256 times”, “1/256 times”, “1/65536 times”, and “65536 times”—like “kilo” means “1000 times”.

Hal Canary | Computers & Code | 2007-10-31 13:46:45 EDT
Permanent Link | Comments Off

Not another calendar reform

A proposal for a better calendar. (If we didn’t have the Gregorian calendar already and wanted to start from scratch.)

No      Name            Days
--      ----            ----
01      January         30
02      February        31
03      March           30
04      April           31
05      May             30
06      June            31
07      July            30
08      August          31
09      September       30
10      October         31
11      November        30
12      December        30 or 31

This would space out the months more equitably. Almost all two-month peroids would be exactly 61 days, the exception being December in non-leap years.

I would define January 1 to be the day after the Winter Solstice (at a fixed zero meridean). So all dates would be around ten days off fromthe Gregorain calendar.

As a result of this rule there would be around 8 leap days every 33 years, similar to how the Iranian/Persian/Jalāli Calendar works.

* * *

Of course the final calendar we will all come to accept millenia from now will probably simply be TAI with picosecond precision, expressed as a number of seconds since some fixed instant. Then calculating intervals become trivially simple, and we will just ignore where the sun is.

* * *

Additional, optional rules to make this a perpetual calendar: January 1 is always a Saturday. Then on 365-day years, you would get two Saturdays in a row:

12-29 12-30 | 01-01 01-02 01-03
 Fri   Sat  |  Sat   Sun   Mon

Or a double weekend on leap years:

12-29 12-30 12-31 | 01-01 01-02 01-03
 Fri   Sat   Sun  |  Sat   Sun   Mon

* * *

Note that one could make the existing Gregorian Calendar into a perpetual calendar by defining March 1 as always a Saturday.

02-27 02-28 | 03-01 03-02 03-03
 Fri   Sat  |  Sat   Sun   Mon
02-27 02-28 02-29 | 03-01 03-02 03-03
 Fri   Sat   Sun  |  Sat   Sun   Mon

* * *

UPDATE 2008-10-25: Here’s very simple python code to give the month, day, and week, given the day of year.

# returns (month, day-of-month, weekday)
# given day-of-year
def dayandmonth(yday):
    assert (yday > 0) and (yday < 367)
    da = ((yday - 1) % 61) + 1
    mo = (((yday - 1) // 61 ) * 2) + 1
    if (da > 30):
        da = da - 30
        mo = mo + 1
    wd = (yday - 1) % 7 +1
    return (mo, da, wd)

And a leap year function:

# offset is determined by solar
# observations at the reference
# longitude
def isleapyear(y):
   offset = 2
   y = (y + offset) % 33
   if (y != 32) and ((y % 4) == 0):
        return True
   else:
        return False

Every 10,000 years, the offset may need to be changed. After 100,000 years, a new algorithm will likely be necessary

Hal Canary | Uncategorized | 2007-10-26 16:45:39 EDT
Permanent Link | Comments Off

the future

Set up my 401k today. I’m now saving for the future again.

I am not saving for retirement. Retirement is for people who plan on eventually dying.

Hal Canary | Life | 2007-10-13 16:55:07 EDT
Permanent Link | Comments Off

« Previous Entries | Next Entries »

Copyright 1997-2007 by Hal Canary.
mailto: h3 at halcanary dot org
xmpp:halcanary@jabber.org
aim:halwcanary
http://halcanary.org