home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / NextLibrary / Frameworks / Foundation.framework / Versions / B / Resources / TimeZoneInfo / README.TimeZoneInfo < prev    next >
Encoding:
Text File  |  1997-03-28  |  4.8 KB  |  114 lines

  1. This time zone data comes from tzdata1996m.tar.gz available at
  2. elsie.nci.nih.gov. Send information or corrections on the contents
  3. of the time zone files to the mail alias tz@elsie.nci.nih.gov.
  4.  
  5. ==========================================================
  6.  
  7. How to Update the Foundation Time Zone Data Files
  8.  
  9. 1. Download the time zone compiler and meta-data files from
  10. ftp://elsie.nci.nih.gov/pub. The files are named tzcode*.tar.gz
  11. and tzdata*.tar.gz, where the "*" part changes as updates are made.
  12. Unpack the archives into a new directory (it works best to unpack
  13. them into the same directory).
  14.  
  15. 2. Compile the time zone compiler (zic) from the tzcode archive.
  16. Changes to the Makefile and/or configuration aren't usually necessary,
  17. but changing the definition of TOPDIR in the Makefile (to /tmp or
  18. /temp, for example) makes the next step somewhat simpler. You may
  19. need to change zic.c to provide definitions for S_IWGRP, S_IWOTH,
  20. F_OK, and perhaps other macros.
  21.  
  22. 3. Using the zic just compiled, compile the data files. This is
  23. simple if you drop the files from tzdata*.tar.gz into the top level
  24. of the directory you unarchived the tzcode archive into. Use the
  25. make target "posix_only". The data files will be put into the
  26. /etc/zoneinfo directory under the directory specified by TOPDIR in
  27. the Makefile.
  28.  
  29. 4. Create a serialized property list from the new time zone data.
  30. This step is optional, but improves use of disk space on a FAT
  31. file system or other file system with large block sizes (on a FAT
  32. file system with a 16K block, the raw time zone data consumes ~8M
  33. of real space while the serialized file consumes ~250K, a factor
  34. of 32). A program which creates such a serialized property list
  35. is located at the bottom of this file (specify the path to the
  36. newly compiled time zones, ${TOPDIR}/etc/zoneinfo, as an argument).
  37. If it exists, the serialized file takes precedence over the
  38. individual time zone files.
  39.  
  40. 5. If you did step 4, move the TimeZones.splist file to the
  41. Foundation's TimeZoneInfo directory. Go to step 7.
  42.  
  43. 6. If you did not do step 4, move the Foundation's TimeZoneInfo
  44. directory out of the way. Then move ${TOPDIR}/etc/zoneinfo to
  45. the previous location of TimeZoneInfo and name the resulting
  46. directory TimeZoneInfo. Finally, copy these files from the old
  47. TimeZoneInfo directory into the new:
  48.     Abbreviation.table
  49.     OldTZToNewTZ.table
  50.     README.TimeZoneInfo
  51.     WindowsName.table
  52.  
  53. 7. You may want to make sure that all the "value strings" in the
  54. WindowsName.table property list still exist as keys within the 
  55. new serialized property list or as files within the new
  56. TimeZoneInfo directory (depending on whether you did step 4).
  57. The serialized file can be dumped into the ASCII property list
  58. format with the "pl -input TimeZones.splist" command at a command
  59. prompt. The OldTZToNewTZ.table is for mapping time zone files that
  60. no longer exist to existant time zone files. Some sites may wish
  61. to customize the Abbreviation.table. If you need to edit any of
  62. these tables, we recommend using TextEdit or other Unicode-capable
  63. editor.  The table files are Unicode (and should stay that way).
  64.  
  65.  
  66. That's it!
  67.  
  68. Note that updating the time zone information may create some
  69. compatibility issues (two machines may believe different things
  70. about summer/daylight saving time for the same location and
  71. date, validity of archives with archived time zones which no
  72. longer exist, etc.).
  73.  
  74.  
  75. ==========================================================
  76.  
  77. #import <Foundation/Foundation.h>
  78.  
  79. // Create a serialized dictionary from a time zone data directory.
  80. // The keys are the names of the time zones and the values are
  81. // data objects containing the compiled information for each time
  82. // zone.  Run with an argument specifying the top level directory
  83. // where the compiled time zone information is. The output file
  84. // will be put in a file called TimeZones.splist in the current
  85. // directory.
  86.  
  87. void main() {
  88.     id pool = [[NSAutoreleasePool allocWithZone:NULL] init];
  89.     id fm, subpaths, arg, args, sd, dict, datas, cd;
  90.     unsigned int idx;
  91.  
  92.     args = [[NSProcessInfo processInfo] arguments];
  93.     if ([args count] < 2) {
  94.     NSLog(@"Too few arguments -- specify a path to the time zone information");
  95.     exit(1);
  96.     }
  97.     arg = [args objectAtIndex:1];
  98.     fm = [NSFileManager defaultManager];
  99.     subpaths = [fm subpathsAtPath:arg];
  100.     cd = [fm currentDirectoryPath];
  101.     [fm changeCurrentDirectoryPath:arg];
  102.     datas = [NSMutableArray array];
  103.     for (idx = 0; idx < [subpaths count]; idx++) {
  104.         id data = [NSData dataWithContentsOfFile:[subpaths objectAtIndex:idx]];
  105.     data ? [datas addObject:data] : [subpaths removeObjectAtIndex:idx--];
  106.     }
  107.     dict = [NSDictionary dictionaryWithObjects:datas forKeys:subpaths];
  108.     sd = [NSSerializer serializePropertyList:dict];
  109.     [fm changeCurrentDirectoryPath:cd];
  110.     [sd writeToFile:@"TimeZones.splist" atomically:NO];
  111.     [pool release];
  112.     exit(0);
  113. }
  114.