gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

64 行
5.3KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>B.2. Handling of Invalid or Ambiguous Timestamps</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="datetime-input-rules.html" title="B.1. Date/Time Input Interpretation" /><link rel="next" href="datetime-keywords.html" title="B.3. Date/Time Key Words" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">B.2. Handling of Invalid or Ambiguous Timestamps</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="datetime-input-rules.html" title="B.1. Date/Time Input Interpretation">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="datetime-appendix.html" title="Appendix B. Date/Time Support">Up</a></td><th width="60%" align="center">Appendix B. Date/Time Support</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="datetime-keywords.html" title="B.3. Date/Time Key Words">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="DATETIME-INVALID-INPUT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">B.2. Handling of Invalid or Ambiguous Timestamps</h2></div></div></div><p>
  3. Ordinarily, if a date/time string is syntactically valid but contains
  4. out-of-range field values, an error will be thrown. For example, input
  5. specifying the 31st of February will be rejected.
  6. </p><p>
  7. During a daylight-savings-time transition, it is possible for a
  8. seemingly valid timestamp string to represent a nonexistent or ambiguous
  9. timestamp. Such cases are not rejected; the ambiguity is resolved by
  10. determining which UTC offset to apply. For example, supposing that the
  11. <a class="xref" href="runtime-config-client.html#GUC-TIMEZONE">TimeZone</a> parameter is set
  12. to <code class="literal">America/New_York</code>, consider
  13. </p><pre class="programlisting">
  14. =&gt; SELECT '2018-03-11 02:30'::timestamptz;
  15. timestamptz
  16. ------------------------
  17. 2018-03-11 03:30:00-04
  18. (1 row)
  19. </pre><p>
  20. Because that day was a spring-forward transition date in that time zone,
  21. there was no civil time instant 2:30AM; clocks jumped forward from 2AM
  22. EST to 3AM EDT. <span class="productname">PostgreSQL</span> interprets the
  23. given time as if it were standard time (UTC-5), which then renders as
  24. 3:30AM EDT (UTC-4).
  25. </p><p>
  26. Conversely, consider the behavior during a fall-back transition:
  27. </p><pre class="programlisting">
  28. =&gt; SELECT '2018-11-04 02:30'::timestamptz;
  29. timestamptz
  30. ------------------------
  31. 2018-11-04 02:30:00-05
  32. (1 row)
  33. </pre><p>
  34. On that date, there were two possible interpretations of 2:30AM; there
  35. was 2:30AM EDT, and then an hour later after the reversion to standard
  36. time, there was 2:30AM EST.
  37. Again, <span class="productname">PostgreSQL</span> interprets the given time
  38. as if it were standard time (UTC-5). We can force the matter by
  39. specifying daylight-savings time:
  40. </p><pre class="programlisting">
  41. =&gt; SELECT '2018-11-04 02:30 EDT'::timestamptz;
  42. timestamptz
  43. ------------------------
  44. 2018-11-04 01:30:00-05
  45. (1 row)
  46. </pre><p>
  47. This timestamp could validly be rendered as either 2:30 UTC-4 or
  48. 1:30 UTC-5; the timestamp output code chooses the latter.
  49. </p><p>
  50. The precise rule that is applied in such cases is that an invalid
  51. timestamp that appears to fall within a jump-forward daylight savings
  52. transition is assigned the UTC offset that prevailed in the time zone
  53. just before the transition, while an ambiguous timestamp that could fall
  54. on either side of a jump-back transition is assigned the UTC offset that
  55. prevailed just after the transition. In most time zones this is
  56. equivalent to saying that <span class="quote">“<span class="quote">the standard-time interpretation is
  57. preferred when in doubt</span>”</span>.
  58. </p><p>
  59. In all cases, the UTC offset associated with a timestamp can be
  60. specified explicitly, using either a numeric UTC offset or a time zone
  61. abbreviation that corresponds to a fixed UTC offset. The rule just
  62. given applies only when it is necessary to infer a UTC offset for a time
  63. zone in which the offset varies.
  64. </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="datetime-input-rules.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="datetime-appendix.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="datetime-keywords.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">B.1. Date/Time Input Interpretation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> B.3. Date/Time Key Words</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1