# This complete implementation of NSTimeZone uses the time zone data at
# http://www.iana.org/time-zones (formerly ftp://elsie.nci.nih.gov/pub/).
# 
# Structure of time zone directory:
# 
# NSTimeZones/
# 	abbreviations - Abbreviation map file
# 	regions - Regions grouped by latitude
# 	zones/ - Saves the files with the time zones
# 
# Install the 'NSTimeZones/' directory in GNUSTEP_INSTALL_LIBDIR
# (e.g. if you configured the library with "./configure
# --prefix=/usr/local", then install it in '/usr/local/lib/gnustep/').
# 
# The file in 'zones/' was created from 'tzcode2011i.tar.gz' and
# 'tzdata2011n.tar.gz' by building and (after minor modification)
# installing the software in those tarballs.
# The install process places the timezone files in
# /usr/local/etc/zoneinfo by default, so they were copied from there to 'zones'.
# The files 'localtime', 'posixrules', 'Factory', 'zone.tab' and 'iso3166.tab'
# were removed.
# Hard links were removed by doing a `cp -R' of the final archive to a
# different directory, and then using that directory.  We removed hard
# links just because RPM (red hat package manager) seems to have
# problems with hard links.

# 1. The tarballs were unpacked.

mkdir /tmp/tz
cd /tmp/tz
# Fetch tarballs via htt
tar -xzf tzcode2011i.tar.gz
tar -xzf tzdata2011n.tar.gz

# 2. The software was built (on GNU/Linux)

make

# 3. GNUstep timezone information was appended to the file 'etcetera' in order
# to provide GMT+/- timezones in OPENSTEP (common usage) format rather than
# Posix format (the Posix style timezones are created in the 'Etc'
# subdirectory).

chmod u+w etcetera
cat `gnustep-config --variable=GNUSTEP_LOCAL_LIBRARY`/Libraries/gnustep-base/Versions/1.23/Resources/NSTimeZones/GNUstep_zones >> etcetera

# 4. The old information (if any) was removed and the timezone files
# were generated and installed (you may need to be logged in as root for
# file permissions).

rm -rf /usr/local/etc/zoneinfo
make install

# 5. The timezone information was copied into the GNUstep zones directory, and
# everything we don't want was removed.

cd `gnustep-config --variable=GNUSTEP_LOCAL_LIBRARY`/Libraries/gnustep-base/Versions/1.23/Resources/NSTimeZones
(cd /usr/local/etc; tar -cf - zoneinfo) | tar -xvf -
rm -rf zones
mv zoneinfo zones
(cd zones; rm -rf localtime posixrules Factory zone.tab iso3166.tab)

# 6. A temporary list of all the zone names was created

find zones -type f -print | sed -e 's/zones\///' > /tmp/tz/zone_names

# 7. The create_abbrevs and create_regions files were built
# 'create-regions' and 'create-abbrevs' only work on systems with the
# GNU C library (e.g. Linux).  This isn't a problem since the
# distributed files work on any system.

make

# 8.  The 'abbreviations' file was created by running 'create-abbrevs' with
# the arguments set to all the possible time zone names.

rm -f abbreviations
for i in `cat /tmp/tz/zone_names`
do
  obj/create-abbrevs $i >> abbreviations
done

# 9. The 'regions' file was created by running 'create-regions' with the
# arguments set to all the possible time zone names.

rm -f regions
for i in `cat /tmp/tz/zone_names`
do
  obj/create-regions $i >> regions
done

# 10. Finally, I tidied up.

rm -rf /tmp/tz
make distclean

# 11. hard links in the `zone' directory were purged

cp -R zones zones.new
rm -Rf zones
mv zones.new zones

# 12. This README file in the
#   `gnustep-config --variable=GNUSTEP_LOCAL_LIBRARY`/Libraries/gnustep-base/Versions/1.23/Resources/NSTimeZones
#   directory was updated.

# 13. The .tar file to be included in the gnustep base distribution 
# was simply obtained at this point by running tar on the 
# `gnustep-config --variable=GNUSTEP_LOCAL_LIBRARY`/Libraries/gnustep-base/Versions/1.23/Resources/NSTimeZones directory:

cd `gnustep-config --variable=GNUSTEP_LOCAL_LIBRARY`/Libraries/gnustep-base/Versions/1.23/Resources
tar cfv NSTimeZones.tar NSTimeZones

# Possible questions
# =======================
# Why do I use the time zone data at http://www.iana.org/time-zones
# instead of using system functions for working with time zones?
# 
# First, time zone names sometimes differ from system to system (Linux
# has "Asia/Seoul", which the Solaris installation I use doesn't).
# 
# Second, at least for strict POSIX the system functions are woefully
# inadequate.  There is no reliable way to obtain the offset from UTC,
# there is absolutely no way to find out what time zone details there
# may be (short of sorting through all time), no way to find a time zone
# name from an abbreviation, etc.
# 
# =======================
# Yoo C. Chung <wacko@laplace.snu.ac.kr>
# 
# Updated August 2000 by R Frith-Macdonald
# Updated (minor) January 2001 by Nicola Pero
# Updated (minor) September 2001 by R Frith-Macdonald
# Updated (minor) March 2002 by R Frith-Macdonald
# Updated (minor) September 2002 by R Frith-Macdonald
# Updated (minor) July 2004 by R Frith-Macdonald
# Updated (minor) October 2004 by R Frith-Macdonald
# Updated (minor) Dec 2004 by A Fedor (Add abbreviations.plist)
# Updated (minor) February 2006 by R Frith-Macdonald
# Updated (minor) August 2006 by R Frith-Macdonald
# Updated (minor) March 2007 by R Frith-Macdonald
# Updated (minor) June 2008 by R Frith-Macdonald
# Updated (minor) October 2008 by R Frith-Macdonald
# Updated (minor) May 2010 by R Frith-Macdonald
# Updated (minor) March 2011 by R Frith-Macdonald
# Updated (minor) June 2011 by R Frith-Macdonald
# Updated (minor) June 2012 by R Frith-Macdonald
