Bläddra i källkod

HPCC-16350 Add docs for some Date Functions

Signed-off-by: Jim DeFabia <jamesdefabia@lexisnexis.com>
Jim DeFabia 8 år sedan
förälder
incheckning
3f49192ebe

+ 88 - 0
docs/ECLStandardLibraryReference/SLR-Mods/AdjustCalendar.xml

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<sect1 id="AdjustCalendar">
+  <title>AdjustCalendar</title>
+
+  <para><emphasis role="bold">STD.Date.AdjustCalendar<indexterm>
+      <primary>STD.Date.AdjustCalendar</primary>
+    </indexterm><indexterm>
+      <primary>Date.AdjustCalendar</primary>
+    </indexterm>(</emphasis> <emphasis>date</emphasis> ,
+  [<emphasis>year_delta</emphasis>],[<emphasis>month_delta</emphasis>]
+  ,[<emphasis>day_delta</emphasis>] <emphasis role="bold">)</emphasis></para>
+
+  <informaltable colsep="1" frame="all" rowsep="1">
+    <tgroup cols="2">
+      <colspec colwidth="80.50pt" />
+
+      <colspec />
+
+      <tbody>
+        <row>
+          <entry><emphasis>date</emphasis></entry>
+
+          <entry>A date value in the Date_t format.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>year_delta</emphasis></entry>
+
+          <entry>The minimum acceptable year. Optional; defaults to
+          zero.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>month_delta</emphasis></entry>
+
+          <entry>The minimum acceptable year. Optional; defaults to
+          zero.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>day_delta</emphasis></entry>
+
+          <entry>The maximum acceptable year. Optional; defaults to
+          zero.</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>AdjustDate returns date_t representing the adjusted
+          date.</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The AdjustCalendar function adjusts a date by incrementing or
+  decrementing months and/or years. The date must be in the Gregorian calendar
+  after the year 1600. </para>
+
+  <para>This uses the rule outlined in McGinn v. State, 46 Neb. 427, 65 N.W.
+  46 (1895):</para>
+
+  <blockquote>
+    <para>"The term calendar month, whether employed in statutes or contracts,
+    and not appearing to have been used in a different sense, denotes a period
+    terminating with the day of the succeeding month numerically corresponding
+    to the day of its beginning, less one. If there be no corresponding day of
+    the succeeding month, it terminates with the last day thereof." </para>
+  </blockquote>
+
+  <para>Note that day adjustments are performed after year and month
+  adjustments using the preceding rules. </para>
+
+  <para>As an example, Jan. 31, 2014 + 1 month results in Feb. 28, 2014; Jan.
+  31, 2014 + 1 month + 1 day results in Mar. 1, 2014.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT std;
+inDate :=19631123;
+Std.Date.AdjustCalendar(inDate,5,1,3);  //returns 19681226
+</programlisting>
+
+  <para>See Also: <link linkend="AdjustDate">AdjustDate</link></para>
+</sect1>

+ 75 - 0
docs/ECLStandardLibraryReference/SLR-Mods/AdjustDate.xml

@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<sect1 id="AdjustDate">
+  <title>AdjustDate</title>
+
+  <para><emphasis role="bold">STD.Date.AdjustDate<indexterm>
+      <primary>STD.Date.AdjustDate</primary>
+    </indexterm><indexterm>
+      <primary>Date.AdjustDate</primary>
+    </indexterm>(</emphasis> <emphasis>date</emphasis> ,
+  [<emphasis>year_delta</emphasis>],[<emphasis>month_delta</emphasis>]
+  ,[<emphasis>day_delta</emphasis>] <emphasis role="bold">)</emphasis></para>
+
+  <informaltable colsep="1" frame="all" rowsep="1">
+    <tgroup cols="2">
+      <colspec colwidth="80.50pt" />
+
+      <colspec />
+
+      <tbody>
+        <row>
+          <entry><emphasis>date</emphasis></entry>
+
+          <entry>A date value in the Date_t format.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>year_delta</emphasis></entry>
+
+          <entry>The minimum acceptable year. Optional; defaults to
+          zero.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>month_delta</emphasis></entry>
+
+          <entry>The minimum acceptable year. Optional; defaults to
+          zero.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>day_delta</emphasis></entry>
+
+          <entry>The maximum acceptable year. Optional; defaults to
+          zero.</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>AdjustDate returns date_t representing the adjusted
+          date.</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The <emphasis role="bold">AdjustDate</emphasis> function adjusts a
+  date by incrementing or decrementing year, month, and/or day values. The
+  date must be in the Gregorian calendar after the year 1600. </para>
+
+  <para>If the new calculated date is invalid then it is normalized according
+  to mktime() rules. For example, 20140130 plus 1 month would be
+  20140302.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT std;
+inDate :=19631123;
+Std.Date.AdjustDate(inDate,5,1,3);  //returns 19681226
+</programlisting>
+
+  <para>See Also: <link linkend="AdjustCalendar">AdjustCalendar</link></para>
+</sect1>

+ 55 - 0
docs/ECLStandardLibraryReference/SLR-Mods/DaysBetween.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<sect1 id="DaysBetween">
+  <title>DaysBetween</title>
+
+  <para><emphasis role="bold">STD.Date.DaysBetween<indexterm>
+      <primary>STD.Date.DaysBetween</primary>
+    </indexterm><indexterm>
+      <primary>DaysBetween</primary>
+    </indexterm>(</emphasis> <emphasis role="bold">fromDate,
+  toDate)</emphasis></para>
+
+  <informaltable colsep="1" frame="all" rowsep="1">
+    <tgroup cols="2">
+      <colspec colwidth="80.50pt" />
+
+      <colspec />
+
+      <tbody>
+        <row>
+          <entry><emphasis>fromDate</emphasis></entry>
+
+          <entry>The first date value in Date_t format.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>toDate</emphasis></entry>
+
+          <entry>The last date value in Date_t format.</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>DaysBetween returns an INTEGER value of the number of days
+          between the two dates.</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The <emphasis role="bold">DayOfYear</emphasis> function calculate the
+  number of whole months between two dates.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT STD;
+StartDate := 19631122;
+numDays := STD.Date.DaysBetween(startDate,STD.Date.Today());
+      // numDays contains the number of days between the startDate and today's date
+</programlisting>
+
+  <para></para>
+</sect1>

+ 65 - 0
docs/ECLStandardLibraryReference/SLR-Mods/IsValidDate.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<sect1 id="IsValidDate">
+  <title>IsValidDate</title>
+
+  <para><emphasis role="bold">STD.Date.IsValidDate<indexterm>
+      <primary>STD.Date.IsValidDate</primary>
+    </indexterm><indexterm>
+      <primary>Date.IsValidDate</primary>
+    </indexterm>(</emphasis> <emphasis>date</emphasis> ,
+  [<emphasis>yearLowerBound</emphasis>],[<emphasis>yearUpperBound</emphasis>]
+  <emphasis role="bold">)</emphasis></para>
+
+  <informaltable colsep="1" frame="all" rowsep="1">
+    <tgroup cols="2">
+      <colspec colwidth="80.50pt" />
+
+      <colspec />
+
+      <tbody>
+        <row>
+          <entry><emphasis>date</emphasis></entry>
+
+          <entry>A date value in the Date_t format.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>yearLowerBound</emphasis></entry>
+
+          <entry>The minimum acceptable year. Optional; defaults to
+          1800.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis><emphasis>yearUpperBound</emphasis></emphasis></entry>
+
+          <entry>The maximum acceptable year. Optional; defaults to
+          2100.</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>IsValidDateLeapYear returns a BOOLEAN value.</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The <emphasis role="bold">IsValidDate</emphasis> function returns TRUE
+  if the date is valid, both by range-checking the year and by validating each
+  of the other individual components.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT STD;
+d1 := 19631122;
+d2 := 19990230;  
+firstTest := STD.Date.IsValidDate(d1);  //d1 is valid
+secondTest := STD.Date.IsValidDate(d2); //d2 is not valid
+</programlisting>
+
+  <para></para>
+</sect1>

+ 55 - 0
docs/ECLStandardLibraryReference/SLR-Mods/MonthsBetween.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<sect1 id="MonthsBetween">
+  <title>MonthsBetween</title>
+
+  <para><emphasis role="bold">STD.Date.MonthsBetween<indexterm>
+      <primary>STD.Date.MonthsBetween</primary>
+    </indexterm><indexterm>
+      <primary>MonthsBetween</primary>
+    </indexterm>(</emphasis> <emphasis role="bold">fromDate,
+  toDate)</emphasis></para>
+
+  <informaltable colsep="1" frame="all" rowsep="1">
+    <tgroup cols="2">
+      <colspec colwidth="80.50pt" />
+
+      <colspec />
+
+      <tbody>
+        <row>
+          <entry><emphasis>fromDate</emphasis></entry>
+
+          <entry>The first date value in Date_t format.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>toDate</emphasis></entry>
+
+          <entry>The last date value in Date_t format.</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>MonthsBetween returns an INTEGER value of the number of whole
+          months between the two dates.</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The <emphasis role="bold">DayOfYear</emphasis> function calculate the
+  number of whole months between two dates.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT STD;
+StartDate := 19631122;
+numMonths := STD.Date.MonthsBetween(startDate,STD.Date.Today());
+      // numMonths contains the number of months between the startDate and today's date
+</programlisting>
+
+  <para></para>
+</sect1>

+ 20 - 0
docs/ECLStandardLibraryReference/SLR-includer.xml

@@ -376,11 +376,16 @@
     <xi:include href="ECLStandardLibraryReference/SLR-Mods/Day.xml"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
 
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/DayOfYear.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />                
+
     <xi:include href="ECLStandardLibraryReference/SLR-Mods/DateFromParts.xml"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
 
     <xi:include href="ECLStandardLibraryReference/SLR-Mods/IsLeapYear.xml"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/IsValidDate.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />
 
     <xi:include href="ECLStandardLibraryReference/SLR-Mods/FromGregorianYMD.xml"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
@@ -389,6 +394,21 @@
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
     <xi:include href="ECLStandardLibraryReference/SLR-Mods/FromStringToDate.xml"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />            
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/Today.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />            
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/DayOfYear.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />            
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/DaysBetween.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />            
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/MonthsBetween.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />            
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/AdjustDate.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />            
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/AdjustCalendar.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />            
+
+
+                
   </chapter>
 
   <chapter id="Cluster_Handling">