FromStringToDate.xml 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
  4. <sect1 id="FromStringToDate">
  5. <title>FromStringToDate</title>
  6. <para><emphasis role="bold">STD.Date.FromStringToDate<indexterm>
  7. <primary>STD.Date.FromStringToDate</primary>
  8. </indexterm><indexterm>
  9. <primary>Date.FromStringToDate</primary>
  10. </indexterm><indexterm>
  11. <primary>FromStringToDate</primary>
  12. </indexterm>(</emphasis> <emphasis>date_text, format</emphasis> <emphasis
  13. role="bold">)</emphasis></para>
  14. <informaltable colsep="1" frame="all" rowsep="1">
  15. <tgroup cols="2">
  16. <colspec colwidth="80.50pt" />
  17. <colspec />
  18. <tbody>
  19. <row>
  20. <entry><emphasis>date_text</emphasis></entry>
  21. <entry>The string to be converted</entry>
  22. </row>
  23. <row>
  24. <entry><emphasis>format</emphasis></entry>
  25. <entry>The format of the input string. See strftime documentation
  26. for details (<ulink
  27. url="http://strftime.org/">http://strftime.org/</ulink>)</entry>
  28. </row>
  29. <row>
  30. <entry>return</entry>
  31. <entry>The date that was matched in the string. Returns 0 if failed
  32. to match or if the date components match but the result is an
  33. invalid date.</entry>
  34. </row>
  35. </tbody>
  36. </tgroup>
  37. </informaltable>
  38. <para>The <emphasis role="bold">FromStringToDate</emphasis> function
  39. converts a string to a Date_t using the relevant string format. The
  40. resulting date must be representable within the Gregorian calendar after the
  41. year 1600.</para>
  42. <para><programlisting>Supported characters:
  43. %B Full month name
  44. %b or %h Abbreviated month name
  45. %d Day of month (two digits)
  46. %e Day of month (two digits, or a space followed by a single digit)
  47. %m Month (two digits)
  48. %t Whitespace
  49. %y year within century (00-99)
  50. %Y Full year (yyyy)
  51. %j Julian day (1-366)
  52. Common date formats
  53. American '%m/%d/%Y' mm/dd/yyyy
  54. Euro '%d/%m/%Y' dd/mm/yyyy
  55. Iso format '%Y-%m-%d' yyyy-mm-dd
  56. Iso basic 'Y%m%d' yyyymmdd
  57. '%d-%b-%Y' dd-mon-yyyy e.g., '21-Mar-1954'
  58. </programlisting></para>
  59. <para>Example:</para>
  60. <programlisting format="linespecific">IMPORT STD;
  61. D1 := STD.Date.FromStringToDate('19720607', '%Y%m%d');
  62. //D1 contains 19720607
  63. D2 := STD.Date.FromStringToDate('19720007', '%Y%m%d');
  64. //D2 contains 0
  65. D3 := STD.Date.FromStringToDate('4/29/1974', '%m/%d/%Y');
  66. //D3 contains 19740429
  67. D4:= STD.Date.FromStringToDate('29/4/1974', '%d/%m/%Y');
  68. //D4 contains 19740429
  69. </programlisting>
  70. <para></para>
  71. </sect1>