Tuesday, March 30, 2010

RFC 3331 and Bash

I've mentioned ISO 8601 here.  As of yesterday, I've started aliasing the shell date(1) command to issue an ISO 8601, RFC 3339 format with the day of the week prepended.

Here's how date(1) normally looks.

Tue Mar 30 06:09:20 EDT 2010

With the bash alias

alias date="date '+%a %Y-%m-%d %H:%M:%S %z'"

The output looks like this…

Tue 2010-03-30 06:06:37 -0400

As you can probably tell, date and time stamps are a big deal with me.

Actually this mostly comes into play inside Emacs where I constantly use macros that insert date and time stamps.

Sadly, the latter format is one character longer than the other style.  The two-digit month is one byte shorter than the three-character abbreviation.  However, the time zone indicator -0400 is two longer than the three-character time zone abbreviation.  Ah well, the cost or progress.