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

  1. Date: 23 Jul 86 08:38:34 +1000 (Wed)
  2. From: Robert Elz <munnari!kre@SEISMO.CSS.GOV>
  3.  
  4. I have (more than) a few comments about some comments
  5. about the timezone proposal.
  6.  
  7. [ There's only one comment from the moderator in this article:
  8. discussions are very useful, but to get in the standard it needs
  9. exact wording.  In other words, anyone wanting changes to the
  10. proposal form I posted should supply *exact wording changes*.
  11. (An alternative would be to submit a complete new proposal.)
  12. -mod ]
  13.  
  14. Quotes until stated otherwise are from Greg Noel (ncr-sd!greg)...
  15.  
  16. > Note that this implies that there must be some way for the implementation
  17. > to tell (a) if settz has been previously called, and presumably, (b) what
  18. > value was provided by settz.
  19.  
  20. I agree, I hadn't considered this.  However, its essential that when
  21. there's an interface that sets some static state, there be some means
  22. to determine the current value of that state - I've been frustrated
  23. so many times by hardware with write only registers that I should
  24. have seen this myself.
  25.  
  26. But, now after thinking about it for a few days, I'm not sure how it
  27. should be done.  There would seem to be two quite different, but
  28. equally possible approaches, though neither is ideal.  One would be
  29. for settz() to save the arg string it is called with, and for a
  30. new function (gettz() ?) to return it.  That sounds simple enough,
  31. but unfortunately might be something of an implementation headache.
  32. The string can be of arbitrary length, so no static buffer in settz
  33. to hold it would be appropriate.  That means that settz would be
  34. required to malloc() memory to hold this string, just on the off
  35. chance that it might be needed later (which it very rarely will be).
  36. I really have very limited enthusiasm for making library routines
  37. at this level get involved in storage allocation.  (Settz could
  38. presumably just remember the pointer to the string it was passed,
  39. and gettz could return that pointer - but this has so many potential
  40. problems that its not worth contemplating).
  41.  
  42. The (an?) other implementation would be to define two functions,
  43. perhaps savetz() and restoretz().  Savetz would return (in some
  44. manner not important here) the internal state that settz has
  45. established.  restoretz() would restablish that state as settz
  46. would have left it.  This might be handled by having savetz
  47. copy the state into a buffer supplied by the caller, or perhaps
  48. it would malloc some memory and return a pointer to that.  Malloc
  49. here is not a problem, as its only being done by the specific
  50. request of the user, its not a hidden side effect.
  51.  
  52. Of the two schemes, I think I prefer the latter, but I would
  53. appreciate comments from readers, either to the list if you
  54. (and the moderator) think there will be general interest in your
  55. comments, or in mail to me.
  56.  
  57.  
  58. I think John Quarterman (our friendly moderator) answered your
  59. query about the "implementors timezone" default possibility
  60. for settz.  I might just add that I can't imagine how a new
  61. implementation could conceivably make that choice - its just
  62. there to cope with old code.  To implement this proposal,
  63. an implementation must be able to obtain both the hosts
  64. local time, and GMT without being told anything externally
  65. (ie: by being handed either (char *)0 or "" resp).  If it
  66. can do that, it can also easily choose one of those as the
  67. default in cases where it is given an invalid argument.
  68.  
  69.  
  70. > I propose an extension of the System V mechanism....  I propose
  71. > that the standard add "extern char *tzname[]" ... and have wording
  72. > that says that tzname[tm.tm_isdst] is the name of the relevant timezone.
  73.  
  74. Yes, this would be nice, unfortunately it can't work.  You are assuming
  75. that there is just one non-DST timezone name, and all the others are
  76. names of various DST types.  This just isn't true in general.
  77. Since tm_isdst must be zero for any tm_* that is not a daylight
  78. savings time representation, your scheme would allow only one
  79. non-DST zone name.  A new field could be added to struct tm to
  80. be the tzname[] index, but this would break all existing code
  81. that wants zone names, and if we're going to do that, perhaps we
  82. should look and see exactly when a zone name is required.
  83.  
  84. To the best of my knowledge, the only sensible use of a timezone
  85. name is to associate with a human visible date/time representation.
  86. Since these things aren't unique, they are useless to hold any
  87. internal representation of a timezone.  In effect, that means
  88. that the only time a timezone name will (should) ever be needed
  89. is when a date/time has been converted for external output, and
  90. the zone that will be wanted will be the zone of the time that
  91. was just converted.
  92.  
  93. If anyone has a counter-example, I would be pleased to learn of it.
  94.  
  95. Given this assumption, it seems that all that's needed is for
  96. localtime() to arrange that the relevant zone name is available
  97. somehow, either in an external "char *" variable, or as the
  98. return value of a function.
  99.  
  100. For Sys V compatability, and implementation could provide
  101. char *tzname[2] and set both pointers to the zone name
  102. needed?  Is anyone aware of any code this would break?
  103.  
  104. For v7 conpatability, the timezone(3) function could be made
  105. to ignore its args, and just return the selected zone name.
  106.  
  107.  
  108. > And while we're on backward compatibility, the SysV function tzset() could
  109. > be defined as "if(timezone_not_set) settz(getenv("TZ");" to be compatible
  110. > with the way it currently works; again, if this function is defined, its
  111. > usage should be depreciated.
  112.  
  113. Certainly, AT&T, and anyone who wants to be compatible with current
  114. Sys V programs should provide tzset as indicated, and should make it,
  115. as far as possible (note "tzname" difficulties as mentioned above)
  116. compatible with the functionality of the Sys V tzset.
  117.  
  118. However, including definitions in the standard, along with wording
  119. like "don't use this, it shouldn't be here, and is going away"
  120. seems ludicrous to me.
  121.  
  122.  
  123. > System V also defines external variables for the current timezone and daylight
  124. > savings rule.
  125.  
  126. I don't know about daylight savings rule, I don't remember that one,
  127. and my Sys V manual seems to have walked away, but "timezone" is
  128. impossible to get right.  There's no doubt that its intended usage
  129. is that tzset() should set this variable to the local standard timezone
  130. offset.  But this assumes that there is such a thing as a "standard
  131. timezone offset" that applies for all times in the zone.  This just
  132. isn't true..  Eg: a couple of years ago now, Singapore (I think)
  133. changed its timezone so it would be the same as Malaysia.  What
  134. value should be put in "timezone" for Singapore?  The correct answer
  135. depends on what time is being converted - if its a time before the
  136. switch, then it should be their old zone, for one after, it should be
  137. the new zone.  That is, its not a constant!
  138.  
  139.  
  140. Following quotes are from Mark Horton (cbosgd!mark)...
  141.  
  142. [about uses of "timezone"]
  143. > Yes, there's an important use.  If you're generating an RFC 822 compatible
  144. > Date: line, you need to know the local offset from GMT...
  145.  
  146. Nonsense!  This isn't a use of the Sys V "timezone" variable at all.
  147. That's not the information it provides.  What you need for an RFC822
  148. Date: line is the numeric offset of the time that was converted.
  149. That's not necessarily the hosts local time zone (which is what
  150. "timezone" is supposed to contain).  And even in cases where host local
  151. time is what is wanted, "timezone" isn't it - as the local time converted
  152. might have been a daylight savings time.  To turn the Sys V "timezone"
  153. into the correct thing in that case, one would need to imbed some
  154. nonsense like "if (tm->tm_isdst) timezone += 60;"  (or maybe -= 60,
  155. and maybe the number is 3600, details are irrelevant.  And no, I
  156. wouldn't really modify "timezone").  Getting rid of assumptions about
  157. things like DST being one hour forwards is one of the major aims of
  158. all this.
  159.  
  160. What *is* needed is a method to obtain the timezone offset that is
  161. appropriate for a given time.  That's a different problem entirely.
  162. An interface to provide this information might be valuable.  If
  163. there isn't such an interface, then the offset can easily calculated
  164. in a portable manner by applications (see my posting to mod.sources,
  165. vol 6 issue 12 "datediffs" for an example of doing approximately this).
  166.  
  167.  
  168. > One might even claim that, in a zone like Japan, asking for the time zone
  169. > name should return "+0900" rather than "JST".  Probably not, but it's
  170. > a thought.
  171.  
  172. This was, of course, a joke (and not even a good one).
  173.  
  174.  
  175. Robert Elz    seismo!munnari!kre   kre%munnari.oz@seismo.css.gov
  176.  
  177. Volume-Number: Volume 6, Number 36
  178.  
  179.