瀏覽代碼

HPCC-16367 Add more date/time functions to Std Lib Ref

Signed-off-by: Jim DeFabia <jamesdefabia@lexisnexis.com>
Jim DeFabia 8 年之前
父節點
當前提交
b5d2928d49

+ 53 - 0
docs/ECLStandardLibraryReference/SLR-Mods/CurrentDate.xml

@@ -0,0 +1,53 @@
+<?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="CurrentDate">
+  <title>CurrentDate</title>
+
+  <para><emphasis role="bold">STD.Date.CurrentDate
+  ([</emphasis><emphasis>in_local_time</emphasis><emphasis
+  role="bold">])</emphasis><indexterm>
+      <primary>STD.Date.CurrentDate</primary>
+    </indexterm><indexterm>
+      <primary>CurrentDate</primary>
+    </indexterm></para>
+
+  <informaltable colsep="1" frame="all" rowsep="1">
+    <tgroup cols="2">
+      <colspec colwidth="80.50pt" />
+
+      <colspec />
+
+      <tbody>
+        <row>
+          <entry><emphasis>in_local_time</emphasis></entry>
+
+          <entry>TRUE if the returned value should be local to the cluster
+          computing the date, FALSE for UTC. Optional, defaults to
+          FALSE.</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>Today returns a Date_t (An UNSIGNED3 holding a time of day in
+          the decimal form HHMMDD.)</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The <emphasis role="bold">CurrentDate</emphasis> function returns the
+  current date. If the in_local_time parameter is TRUE the returned value is
+  local to the cluster computing the date, if FALSE then the UTC value is
+  returned.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT STD;
+d1 := STD.Date.CurrentDate(True); 
+     //d1 contains the current local date 
+</programlisting>
+
+  <para></para>
+</sect1>

+ 52 - 0
docs/ECLStandardLibraryReference/SLR-Mods/IsDateLeapYear.xml

@@ -0,0 +1,52 @@
+<?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="IsDateLeapYear">
+  <title>IsDateLeapYear</title>
+
+  <para><emphasis role="bold">STD.Date.IsDateLeapYear<indexterm>
+      <primary>STD.Date.IsDateLeapYear</primary>
+    </indexterm><indexterm>
+      <primary>Date.IsDateLeapYear</primary>
+    </indexterm>(</emphasis> <emphasis>date</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 in Date_t format. (An UNSIGNED4 containing a date
+          value in YYYYMMDD format.)</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>IsDateLeapYear returns a BOOLEAN value.</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The <emphasis role="bold">IsDateLeapYear</emphasis> function returns
+  TRUE if the <emphasis>year</emphasis> represented in the
+  <emphasis>date</emphasis> is a leap year in the Gregorian (or proleptic
+  Gregorian) calendar.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT STD;
+MyDate := 20120112;   //Jan. 12, 2012
+  
+D := STD.Date.IsDateLeapYear(MyDate);
+    //D contains TRUE, 2012 is a leap year
+  </programlisting>
+
+  <para></para>
+</sect1>

+ 1 - 1
docs/ECLStandardLibraryReference/SLR-Mods/IsValidDate.xml

@@ -42,7 +42,7 @@
         <row>
           <entry>Return:</entry>
 
-          <entry>IsValidDateLeapYear returns a BOOLEAN value.</entry>
+          <entry>IsValidDateYear returns a BOOLEAN value.</entry>
         </row>
       </tbody>
     </tgroup>

+ 51 - 0
docs/ECLStandardLibraryReference/SLR-Mods/IsValidGregorianDate.xml

@@ -0,0 +1,51 @@
+<?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>IsValidGregorianDate</title>
+
+  <para><emphasis role="bold">STD.Date.IsValidGregorianDate<indexterm>
+      <primary>STD.Date.IsValidGregorianDate</primary>
+    </indexterm><indexterm>
+      <primary>Date.IsValidGregorianDate</primary>
+    </indexterm>(</emphasis> <emphasis>date</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. (An UNSIGNED4 containing a
+          date value in YYYYMMDD format.)</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>IsValidGregorianDateYear returns a BOOLEAN value.</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The <emphasis role="bold">IsValidGregorianDate</emphasis> function
+  returns TRUE if the date is valid in the Gregorian calendar. The year must
+  be between 1601 and 30827.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT STD;
+d1 := 19991122;
+d2 := 15130230;  
+firstTest := STD.Date.IsValidGregorianDate(d1);  //  TRUE
+secondTest := STD.Date.IsValidGregorianDate(d2); //  FALSE
+</programlisting>
+
+  <para></para>
+</sect1>

+ 50 - 0
docs/ECLStandardLibraryReference/SLR-Mods/IsValidTime.xml

@@ -0,0 +1,50 @@
+<?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>IsValidTime</title>
+
+  <para><emphasis role="bold">STD.Date.IsValidTime<indexterm>
+      <primary>STD.Date.IsValidTime</primary>
+    </indexterm><indexterm>
+      <primary>Date.IsValidTime</primary>
+    </indexterm>(</emphasis> <emphasis>time</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>time</emphasis></entry>
+
+          <entry>A time value in the Time_t format.</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>

+ 66 - 0
docs/ECLStandardLibraryReference/SLR-Mods/TimeFromParts.xml

@@ -0,0 +1,66 @@
+<?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="TimeFromParts">
+  <title>TimeFromParts</title>
+
+  <para><emphasis role="bold">STD.Date.TimeFromParts<indexterm>
+      <primary>STD.Date.TimeFromParts</primary>
+    </indexterm><indexterm>
+      <primary>Date.TimeFromParts</primary>
+    </indexterm>(</emphasis> <emphasis>hour, minute, second</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>hour</emphasis></entry>
+
+          <entry>An INTEGER1 hour value in the range 0 to 23.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>minute</emphasis></entry>
+
+          <entry>An UNSIGNED1 minute value in the range 0 to 59.</entry>
+        </row>
+
+        <row>
+          <entry><emphasis>second</emphasis></entry>
+
+          <entry>An UNSIGNED1 second value in the range 0 to 59.</entry>
+        </row>
+
+        <row>
+          <entry>Return:</entry>
+
+          <entry>TimeFromParts returns a Time_t (An UNSIGNED3 holding a time
+          of day in the decimal form HHMMDD.)</entry>
+        </row>
+      </tbody>
+    </tgroup>
+  </informaltable>
+
+  <para>The <emphasis role="bold">TimeFromParts</emphasis> function returns a
+  Time_t value from the <emphasis>hour</emphasis>,
+  <emphasis>minute</emphasis>, and <emphasis>second</emphasis>
+  parameters.</para>
+
+  <para>Example:</para>
+
+  <programlisting format="linespecific">IMPORT STD;
+  UNSIGNED1   MyHour   := 23;
+  UNSIGNED1   MyMinute := 59;
+  UNSIGNED1   MySecond := 50;
+  
+T := STD.Date.TimeFromParts(MyHour,MyMinute,MySecond);
+    //T contains 235950
+  </programlisting>
+
+  <para></para>
+</sect1>

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

@@ -384,12 +384,21 @@
 
     <xi:include href="ECLStandardLibraryReference/SLR-Mods/DateFromParts.xml"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/TimeFromParts.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/IsDateLeapYear.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/IsValidTime.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/IsValidGregorianDate.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" />
@@ -402,6 +411,8 @@
 
     <xi:include href="ECLStandardLibraryReference/SLR-Mods/Today.xml"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
+    <xi:include href="ECLStandardLibraryReference/SLR-Mods/CurrentDate.xml"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />
 
     <xi:include href="ECLStandardLibraryReference/SLR-Mods/CurrentTime.xml"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />