gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
6.7KB

  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.1. Date/Time Input Interpretation</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-appendix.html" title="Appendix B. Date/Time Support" /><link rel="next" href="datetime-invalid-input.html" title="B.2. Handling of Invalid or Ambiguous Timestamps" /></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.1. Date/Time Input Interpretation</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="datetime-appendix.html" title="Appendix B. Date/Time Support">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-invalid-input.html" title="B.2. Handling of Invalid or Ambiguous Timestamps">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="DATETIME-INPUT-RULES"><div class="titlepage"><div><div><h2 class="title" style="clear: both">B.1. Date/Time Input Interpretation</h2></div></div></div><p>
  3. Date/time input strings are decoded using the following procedure.
  4. </p><div class="procedure"><ol class="procedure" type="1"><li class="step"><p>
  5. Break the input string into tokens and categorize each token as
  6. a string, time, time zone, or number.
  7. </p><ol type="a" class="substeps"><li class="step"><p>
  8. If the numeric token contains a colon (<code class="literal">:</code>), this is
  9. a time string. Include all subsequent digits and colons.
  10. </p></li><li class="step"><p>
  11. If the numeric token contains a dash (<code class="literal">-</code>), slash
  12. (<code class="literal">/</code>), or two or more dots (<code class="literal">.</code>), this is
  13. a date string which might have a text month. If a date token has
  14. already been seen, it is instead interpreted as a time zone
  15. name (e.g., <code class="literal">America/New_York</code>).
  16. </p></li><li class="step"><p>
  17. If the token is numeric only, then it is either a single field
  18. or an ISO 8601 concatenated date (e.g.,
  19. <code class="literal">19990113</code> for January 13, 1999) or time
  20. (e.g., <code class="literal">141516</code> for 14:15:16).
  21. </p></li><li class="step"><p>
  22. If the token starts with a plus (<code class="literal">+</code>) or minus
  23. (<code class="literal">-</code>), then it is either a numeric time zone or a special
  24. field.
  25. </p></li></ol></li><li class="step"><p>
  26. If the token is an alphabetic string, match up with possible strings:
  27. </p><ol type="a" class="substeps"><li class="step"><p>
  28. See if the token matches any known time zone abbreviation.
  29. These abbreviations are supplied by the configuration file
  30. described in <a class="xref" href="datetime-config-files.html" title="B.4. Date/Time Configuration Files">Section B.4</a>.
  31. </p></li><li class="step"><p>
  32. If not found, search an internal table to match
  33. the token as either a special string (e.g., <code class="literal">today</code>),
  34. day (e.g., <code class="literal">Thursday</code>),
  35. month (e.g., <code class="literal">January</code>),
  36. or noise word (e.g., <code class="literal">at</code>, <code class="literal">on</code>).
  37. </p></li><li class="step"><p>
  38. If still not found, throw an error.
  39. </p></li></ol></li><li class="step"><p>
  40. When the token is a number or number field:
  41. </p><ol type="a" class="substeps"><li class="step"><p>
  42. If there are eight or six digits,
  43. and if no other date fields have been previously read, then interpret
  44. as a <span class="quote">“<span class="quote">concatenated date</span>”</span> (e.g.,
  45. <code class="literal">19990118</code> or <code class="literal">990118</code>).
  46. The interpretation is <code class="literal">YYYYMMDD</code> or <code class="literal">YYMMDD</code>.
  47. </p></li><li class="step"><p>
  48. If the token is three digits
  49. and a year has already been read, then interpret as day of year.
  50. </p></li><li class="step"><p>
  51. If four or six digits and a year has already been read, then
  52. interpret as a time (<code class="literal">HHMM</code> or <code class="literal">HHMMSS</code>).
  53. </p></li><li class="step"><p>
  54. If three or more digits and no date fields have yet been found,
  55. interpret as a year (this forces yy-mm-dd ordering of the remaining
  56. date fields).
  57. </p></li><li class="step"><p>
  58. Otherwise the date field ordering is assumed to follow the
  59. <code class="varname">DateStyle</code> setting: mm-dd-yy, dd-mm-yy, or yy-mm-dd.
  60. Throw an error if a month or day field is found to be out of range.
  61. </p></li></ol></li><li class="step"><p>
  62. If BC has been specified, negate the year and add one for
  63. internal storage. (There is no year zero in the Gregorian
  64. calendar, so numerically 1 BC becomes year zero.)
  65. </p></li><li class="step"><p>
  66. If BC was not specified, and if the year field was two digits in length,
  67. then adjust the year to four digits. If the field is less than 70, then
  68. add 2000, otherwise add 1900.
  69. </p><div class="tip"><h3 class="title">Tip</h3><p>
  70. Gregorian years AD 1-99 can be entered by using 4 digits with leading
  71. zeros (e.g., <code class="literal">0099</code> is AD 99).
  72. </p></div><p>
  73. </p></li></ol></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="datetime-appendix.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-invalid-input.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix B. Date/Time Support </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> B.2. Handling of Invalid or Ambiguous Timestamps</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1