home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / mod.std.unix.v5 / text0049.txt < prev    next >
Encoding:
Internet Message Format  |  1987-06-30  |  9.4 KB

  1. Date: Fri, 14 Feb 86 00:51:16 PST
  2. >From: sun!guy@seismo.UUCP (Guy Harris)
  3.  
  4. >      The major points of the proposal are:
  5. >    
  6. >            1. There is a world-readable, superuser-modifiable file
  7. >               named "/etc/TIMEZONE" that describes the per-system
  8. >               timezone information and Daylight Saving Time rules.
  9.  
  10. Too specific.  The standard should not give all the implementation details.
  11. Giving this much detail merely constrains an implementation to use the
  12. particular technique specified, even if it isn't the appropriate technique
  13. to use (on a V7 or 4BSD system, for instance, fetching it from the kernel is
  14. more appropriate, since it's already there).
  15.  
  16. >            3. The TZ variable has 2 required parts (and an optional 3rd):
  17. >    
  18. >               A = standard abbreviation for the timezone as used by the
  19. >                local area
  20. >                    A :== [A-Z][A-Z]*
  21. >               B = plus or minus difference in minutes from Universal Time,
  22. >               plus for those locations east of GMT, minus for west
  23. >                   B :== [+-][0-9][0-9][0-9]
  24. >               C = standard abbreviation for the timezone as used by the
  25. >                local area when Daylight Saving Time is in effect.  This
  26. >            part of TZ may be absent if DST is not used.
  27. >                   C :== [A-Z][A-Z]*
  28.  
  29. Unnecessarily incompatible with System V, which specifies the offset from
  30. Universal Time in hours.  (It also requires you to multiply an offset in
  31. hours by 60, which is much better done by a computer.)  See below for a
  32. better way of specifying offsets which aren't an integral number of hours.
  33.  
  34. >            4. The DST variable has 0 or 2 parts in the string.  It has
  35. >               zero if no Daylight Saving Time is observed or 2, when DST
  36. >               starts and ends, for those places that do observe it.
  37.  
  38. Not sufficient.  The routines that convert between GMT and local time can be
  39. given a time not in the current year; if the time is in a year prior to the
  40. current one, these routines must still be able to convert it, and must
  41. therefore know the rules for all years prior to the current one.  (The
  42. 4.2BSD source indicates that the rules for 1970, 1971, and 1972 in Australia
  43. were all rather different; 1970 had no daylight savings time, 1971 had it
  44. from October 31 to the end of the year, 1972 had it from January 1 to
  45. February 27 and October 31 to December 31, and all subsequent years had it
  46. January 1 to March 7 and October 31 to December 31.  In the US, of course,
  47. we had the infamous "nixonflag" for 1974 and 1975....)  For times in the
  48. future, of course, it will have to rely on a projection (if it could handle
  49. times in the future exactly, I'd put it to work on Sun's stock price...).
  50.     
  51. >            7. TZ and DST are put into the environment of each user
  52. >               when the user logs in.
  53. >
  54. >            8. Those utilities that strip off environment information
  55. >               can obtain TZ and DST values by reading "/etc/TIMEZONE".
  56.  
  57. What puts TZ and DST into the environment of each user?  If it's not done by
  58. "login", then every program which is used as a login shell must do it.  A
  59. LOT of UNIX systems have many users who log in to a specific application,
  60. which may never run the shell.  As such, it should be done by "login", which
  61. makes the Bourne shell syntax unhelpful.
  62.  
  63. And what about utilities not run by a logged-in user?  Must they look in
  64. "/etc/TIMEZONE"?  If so, do they have to do their own parsing?  There is
  65. already a routine in System V called "tzset()", which sets the global
  66. variables "timezone" and "daylight".  In vanilla S5, it just scans the TZ
  67. environment variable (which means you have to go through contortions to get
  68. that variable set).  In systems which have a source for time zone
  69. information other than TZ, they can scan TZ if present and non-null, and use
  70. that source otherwise.  In your proposal, "tzset()" should scan that file.
  71. However, we have now eliminated the need for any program to look at
  72. "/etc/TIMEZONE" directly - they should let "tzset()" do it for them.
  73.  
  74. The trouble is that there are several ways of storing the time zone
  75. information, other than in the TZ environment variable.  V7 stored it,
  76. in effect, in "/unix"; you specified it when you built your kernel.  4.2BSD
  77. also stores it there (in "/vmunix", actually); you can specify it when you
  78. build your kernel, but you can also specify it with the "settimeofday"
  79. system call.  A system running on a machine with an EEPROM might store the
  80. time zone there, and either read it out when the machine is booted or make
  81. it readable by user programs.  A "hosted" system (i.e., a system which
  82. provides a P1003-compatible environment on top of an existing operating
  83. system) might be able to get it out of the host operating system.  A table
  84. containing this operation might be mapped into the address space of all
  85. processes in any of a number of ways, depending on the memory model of the
  86. OS and the whims of the OS's designers.
  87.  
  88. It's inappropriate to commit to something as specific as "/etc/TIMEZONE";
  89. "tzset()" should be specified as fetching the appropriate information and
  90. setting the "timezone", "daylight", and "tzname" external variables (System
  91. V-style) and also arranging, somehow, for the daylight savings time rules to
  92. be set up.
  93.  
  94. The only copy of the X3J11 C standard draft I can get my hands on right now
  95. is an old one.  It lists "asctime", "ctime", "gmtime", and "localtime" as
  96. being like their UNIX versions, but doesn't list "tzset", "timezone",
  97. "daylight", or "tzname".  Presumably, it considers them to be part of the
  98. operating system (or environment) rather than the C language/library.  (Have
  99. they been added in later drafts?)  If they haven't been added in later
  100. drafts, I propose that P1003 adopt the System V versions, as specified in
  101. the System V Interface Definition, with the following change:
  102.  
  103. change
  104.  
  105.     ...the external variable "daylight" is non-zero only if the
  106.     standard U.S.A. Daylight Savings Time conversion should be
  107.     applied.  The program compensates for the peculiarities
  108.     of this conversion in 1974 and 1975; if necessary, a table
  109.     for these years can be extended.
  110.  
  111.     If an environment variable named TZ is present, "asctime" uses the
  112.     contents of the variable to override the default time zone.  The
  113.     value of TZ must be a three-letter time zone name, followed
  114.     by an optional minus sign (for zones east of Greenwich) and
  115.     a series of digits representing the difference between local time
  116.     and Greenwich Mean Time in hours; this is followed by an
  117.     optional three-letter name for a daylight time zone.
  118.  
  119. to
  120.  
  121.     ...the external variable "daylight" is non-zero only if the
  122.     standard Daylight Savings Time conversion for the current time
  123.     zone, if any, should be applied.  The external variable "tzname"
  124.     contains pointers to the name of the time zone when daylight
  125.     savings time is    not in effect and when it is in effect in its
  126.     first and second members, respectively.
  127.  
  128.     The default time zone is settable by the system administrator,
  129.     and is usually the time zone that the majority of the system's
  130.     users are in.  "tzset" normally sets the variables "timezone",
  131.     "daylight", and "tzname" to the values for the default time zone.
  132.     If an environment variable named TZ is present, "tzset" sets the
  133.     variables "timezone", "daylight", and "tzname" from the value
  134.     of this environment variable.  The value of TZ must either be
  135.     of the form "GMT+hh[:mm]", or "GMT-hh[:mm]", specifying an
  136.     unnamed time zone "hh" hours and "mm" minutes ahead of or behind
  137.     Universal Time (if "mm" is not present, it is assumed to be
  138.     zero), or a zone name followed by an optional minus sign (for
  139.     zones east of Greenwich) and a specification of the form "hh[:mm]"
  140.     specifying the difference between local time and Universal Time
  141.     in hours and minutes; this is followed by an optional name for the
  142.     time zone when Daylight Savings Time is in effect.  A time zone name
  143.     must not contain any digits and must not contain the characters "+",
  144.     "-", or ":".  If an unnamed zone is specified, Daylight Savings
  145.     time rules are considered not to apply, and the time zone name is
  146.     assumed to be the value of the TZ environment variable.
  147.  
  148. I include the "GMT+/-hh:mm" specification on the assumption that there are
  149. unnamed time zones; if this is not so, this part may be deleted.  Note that
  150. unlike the System V TZ value, this permits time zone names to be longer or
  151. shorter than 3 characters.  It also permits fractional-hour time zone
  152. offsets; it uses a different syntax than the one described in the "FUTURE
  153. DIRECTIONS" section, because that section doesn't indicate whether the
  154. time zone offset must be four digits (which would mean that EST5EDT would no
  155. longer be valid) or not (which would mean that OLT7ODT would be ambiguous -
  156. is Out to Lunch Time 7 hours away from GMT or 7 minutes?).  The proposed
  157. syntax is an upward-compatible extension of the current syntax, which the
  158. syntax in the "FUTURE DIRECTIONS" section is not.
  159.  
  160. If TZ is not set, "tzset" will presumably get the Daylight Savings Time
  161. rules from some standard place (where it gets them from is an implementation
  162. detail which does not belong in P1003).  If TZ is set, there should be some
  163. indication of where it gets the DST rules from.  It can either get them from
  164. some "standard" database of rules, or from an environment variable (either
  165. from additional data at the end of TZ, or from DST), or both (i.e., if the
  166. rules aren't specified in an environment variable, it uses the time zone
  167. specified in TZ to look up the rules in the standard database).
  168.  
  169. Volume-Number: Volume 5, Number 50
  170.  
  171.