Tivotime Package Copyright (c) 2004 Warren Toomey and others The tivotime package is a set of C library functions that properly deal with timezones for the TiVo, plus two application programs. Please see the respective files for their copyright details. The licenses are either GPL or BSD licenses. Installing the Programs ----------------------- Obtain the tivotime-bin.tar.gz file, download it to your TiVo in binary mode, and extract it in the root directory: # cd / # tar vxzf tivotime-bin.tar.gz This will create these files and directories: /etc/postcodezones # Database of postcodes -> timezones /var/hack/ # Directory to hold new programs /var/hack/bin/get_postalcode # Program to get this TiVo's postcode /var/hack/bin/ntpdate # Set the TiVo's clock using a time server /var/hack/bin/k9tivo # Receive NTP broadcasts, set the TiVo's clock /var/hack/zoneinfo/ # Directory holding zoneinfo databases You must make sure that your / partition is writable before you extract the tarball, otherwise it will fail when extracting /etc/postcodezones. On OzTiVos, the "rw" command will make the / partition writable. Setting the TZ Environment Variable ----------------------------------- The libraries and programs can determine the TiVo's timezone in two ways. If you have set the TZ environment variable, then the TZ variable names the timezone. For example, do: # export TZ="Australia/Sydney" to set the TZ environment variable. NOTE: this only lasts while your shell is running, so it will disappear when you log out. You might want to put the command in your .bash_profile file. If you don't want to set the TZ environment variable and you have an OzTiVo, then the programs will run the /var/hack/bin/get_postalcode to get the TiVo's postcode from the MFS database, and then look in /etc/postcodezones to convert the postcode to a correct TZ environment variable. Application Programs - ntpdate ------------------------------ Ntpdate is a drop-in replacement for the /bin/ntpdate program on the TiVo. Unlike the real ntpdate, this ntpdate doesn't use NTP, but uses TCP port 37 to get the UTC time from a remote timeserver. This is then converted to the local time and the TiVo's clock is updated. Usage: ntpdate [-B] [-b] [d] [-q] [-v] server [server ...] -B, -b These do nothing, just for real ntpdate compatibility -d, -q Don't actually set the time, but still query the server -v Verbose, print messages to the console You can specify a number of time servers on the command line. If ntpdate cannot contact the first timeserver, it will move on to the others in the list. You should be able to copy or link /var/hack/bin/ntpdate over the top of /bin/ntpdate with no side effects. So, you can do something like this: # rm /bin/ntpdate # ln -s /var/hack/bin/ntpdate /bin/ntpdate Here are a list of available time servers: time-a.nist.gov 129.6.15.28 NIST, Gaithersburg, Maryland time-b.nist.gov 129.6.15.29 NIST, Gaithersburg, Maryland time-a.timefreq.bldrdoc.gov 132.163.4.101 NIST, Boulder, Colorado time-b.timefreq.bldrdoc.gov 132.163.4.102 NIST, Boulder, Colorado time-c.timefreq.bldrdoc.gov 132.163.4.103 NIST, Boulder, Colorado utcnist.colorado.edu 128.138.140.44 University of Colorado, Boulder time.nist.gov 192.43.244.18 NCAR, Boulder, Colorado time-nw.nist.gov 131.107.1.10 Microsoft, Redmond, Washington nist1.datum.com 66.243.43.21 Datum, San Jose, California nist1-dc.glassey.com 216.200.93.8 Abovenet, Virginia nist1-ny.glassey.com 208.184.49.9 Abovenet, New York City nist1-sj.glassey.com 207.126.98.204 Abovenet, San Jose, California nist1.aol-ca.truetime.com 207.200.81.113 TrueTime, AOL facility, Sunnyvale, California nist1.aol-va.truetime.com 205.188.185.33 TrueTime, AOL facility, Virginia ntpdate is derived from tridge's rtime program. Application Programs - k9tivo ----------------------------- k9tivo runs in the background listening for NTP broadcast packets in the local network. When it receives an NTP broadcast, the UTC timestamp is converted to the local time and the TiVo's clock is updated. Usage: k9tivo [-b][-d][-o][-s][-m multicast_address] -b Beep when packet received -d Debug mode, don't run in the background, print debug messages -o Run until a packet is received then die -s Log messages to syslog when the time is set -m Listen on the given multicast address, not the broadcast address You might like to add this program to your /etc/rc.d/rc.sysinit.author startup script as follows: export TZ="Australia/Sydney" /var/hack/bin/k9tivo k9tivo is derived from H.C.Mingham-Smith's k9linux program. Library Functions ----------------- The localtime.c file contains the various localtime() functions. The file is inherited from FreeBSD and is under a BSD license. The tivotimelib.c file contains two TiVo-specific functions: void set_tz_variable(void) Obtain the postcode from the MFS database, use /etc/postcodezones to determine the correct timezone, and set the TZ environment variable. long get_timezone_offset(int hoursago) Get the current time offset from UTC for the TiVo's timezone, in seconds. Locations east of Greenwich have positive offsets, locations west of Greenwich have negative offsets. If the TZ variable is not set, this function calls set_tz_variable(). The hoursago input variable is used to get the offset for right now (hoursago=0) or for N hours ago (hoursago=N). This can be used to determine if we are transiting through a daylight-saving change. /etc/postcodezones ------------------ The /etc/postcodezones file looks like this: # A list of TiVo postcodes and the timezones that they represent # Two columns, separated by a single tab. # 00800 Australia/Darwin 02000 Australia/Sydney 02600 Australia/Sydney 03000 Australia/Melbourne 04000 Australia/Brisbane 05000 Australia/Adelaide 06000 Australia/Perth 07000 Australia/Hobart *** Be careful that this doesn't end up with MS-DOS characters on the end of each line: that stops the timezone lookup from working (I know).