Internet Beat

This script does not work correctly in Netscape 2, Explorer 3 on Windows and Konqueror because they have problems with the getTimezoneOffset() method.

Netscape 3 and 4 on Mac also have a bug in getTimezoneOffset() but this script takes care of it.

It does not work correctly in Opera 5 on Mac because with this script (but not with the generic Date and time script) this browser is one hour in advance of system time.

On my own computers this script hasn’t survived the start of Daylight Saving Time: it’s off by one hour. However, on other computers it still works fine.
If you could check if this script gives the correct Beat time and contact me if it doesn’t I’d be very happy.

The Internet Beat is a new measure of time, meant especially for the Internet. It divides the day into 1000 beats of 86.4 seconds each. It is written with an @ in front of it. The great advantage of it is that it offers a truly worldwide time, so that people in wildly different timezones can agree to mail each other "around @600".

Internet Beat

Internet Beat has been invented by Swatch and has generally been received favourably by the Internet community.

I myself have helped writing the original JavaScript implementation for the Swatch site. In 1999 there came a complex query about date and time on a mailing list. I didn't really understand why the programmer wanted to measure intervals of 86.4 seconds, but I helped solve the problem and forgot all about it. More than a year later I found out what Internet Beats were supposed to do and I liked the idea. I also remembered the JavaScript problem.

The main problem is that, since Swatch's corporate headquarters are in Switzerland, @0 is defined as midnight in the Central European timezone (and @500 as noon in CET). I don't mind this as such, I myself live in the CET zone, but writing a script becomes more difficult because there's no certain way to transform a local time string to CET.

Example

The current Internet Beat time is .

Assumptions

The simple script I wrote rests on two assumptions:

  1. The browsers themselves take care of daylight saving time.
    This assumption is not perfect, see the Date and time page for the gory details, but incorporating DST in the script would have made it at least 5 times as long. Besides, I wouldn't know how to write it except for using a (<gasp />) browser detect or using immense tables of time zones, as the Swatch script does.
  2. The difference between CET and GMT is always exactly one hour.
    Fortunately the European Union has standardized DST for its member states so that it goes into effect in all countries simultaneously, even in the UK (a difficult member at best) and Switzerland (not a member at all). So this appears to be a valid assumption.

The script

The script is very simple:

function getBeat()
{
	var now = new Date();
	var off = (now.getTimezoneOffset() + 60)*60;
	var theSeconds = (now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + off;
	var beat = Math.floor(theSeconds/86.4);
	if (beat > 1000) beat -= 1000;
	if (beat < 0) beat += 1000;
	return beat;
}

Explanation

First of all take the current date according to the computer the browser is on, in its local time zone

function getBeat()
{
	var now = new Date();

Then take the TimezoneOffset, the difference between local time and GMT time, in minutes. Add 60 to this to get the CET time, always one hour in advance of GMT. Multiply by 60 to get the offset in seconds.

	var off = (now.getTimezoneOffset() + 60)*60;

Now calculate the day time in seconds by taking the hours, multiplying them by 3600, then the minutes, multiplied by 60, the seconds and the calculated offset.

	var theSeconds = (now.getHours() * 3600) + (now.getMinutes() * 60) + now.getSeconds() + off;

Divide this number by 86.4 and make it an integer to get the time in Internet Beats.

	var beat = Math.floor(theSeconds/86.4);

A slight bug defeating rule: Netscape 3 and 4 on Mac give a wrong timezoneoffset so that the beat may be exactly 1000 too high or too low. If it's more than 1000, subtract 1000, if it's less than zero, add 1000.

	if (beat > 1000) beat -= 1000;
	if (beat < 0) beat += 1000;

Finally return the Internet Beat to whichever function asked for it.

	return beat;
}