⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jtime_c.htm

📁 The goal of this library is to make ODBC recordsets look just like an STL container. As a user, you
💻 HTM
字号:
<html>

 
<head>
<style>
CODE {COLOR: #990000;}
.code{COLOR: #990000}
.codeComment{COLOR: #008000}
.codeHighlight{BACKGROUND-COLOR: #FFFF00}
.codeFileName{FONT-WEIGHT: bold;}
</style>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="Author" content="Mike Gradman">
<meta name="KeyWords"
content="DTL, Oracle, ODBC, database API, C++, Template Library">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<!--
  -- Copyright 2000
  -- Michael Gradman & Corwin Joy
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Corwin Joy & Michael Gradman make no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  --
  -- Copyright (c) 1996-1999
  -- Silicon Graphics Computer Systems, Inc.
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Silicon Graphics makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -- Copyright (c) 1994
  -- Hewlett-Packard Company
  --
  -- Permission to use, copy, modify, distribute and sell this software
  -- and its documentation for any purpose is hereby granted without fee,
  -- provided that the above copyright notice appears in all copies and
  -- that both that copyright notice and this permission notice appear
  -- in supporting documentation.  Hewlett-Packard Company makes no
  -- representations about the suitability of this software for any
  -- purpose.  It is provided "as is" without express or implied warranty.
  --
  -->
<!-- Generated by htmldoc -->
<title>jtime_c</title>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#0000EE"
vlink="#551A8B" alink="#FF0000">

<p><font size="6" face="Bookman Old Style"><em><strong><u>dtl</u></strong></em></font></p>

<p><img src="stat.gif" width="6" height="6"> <!--end header--> <br>
</p> 

<h1>jtime_c</h1>

 

















<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td><img src="utilities.gif" width="194" height="38"></td>
        <td align="right"><img src="type.gif" width="194"
        height="39"></td>
    </tr>
    <tr>
        <td valign="top"><b>Category</b>: utilities</td>
        <td align="right" valign="top"><b>Component type</b>:
        type</td>
    </tr>
</table>
<h3>Description</h3>

<p><font size="2" face="Courier New">jtime_c</font> objects
represent Julian dates. This class supports dates from Jan. 1,
1970 to Jan. 1, 4000. <font size="2" face="Courier New">jtime_c </font>objects
can be converted freely into SQL timestamps (<font size="2"
face="Courier New">TIMESTAMP_STRUCT's) or jtime_t </font>values (<font
size="2" face="Courier New">long </font><font size="3">indicating
the number of seconds elapsed since Jan. 1, 1970, midnight).</font></p>

<h3>Definition</h3>

<p>Defined in the <font size="2" face="Courier New">date_util.h </font><font
size="3">header file. </font></p>

<h3>Refinement of</h3>

<p>None.</p>

<h3>Associated types</h3>

<pre>typedef struct tag_jtime_tm {
  int   sec;		// Seconds after the minute (0, 61)
  int   min;		// minutes after the hour (0, 59)
  int   hour;		// hours since midnight (0, 23)
  int   day;		// day of the month
  int   mon;		// month number (1, 12)
  int   year;		// year number (AD)
} jtime_tm;</pre>

<h3>Public base classes:</h3>

<p>None.</p>

<h3>Example:</h3>

<pre>
See date_unit_test() in date_util.cpp.
</pre>

<h3>Notation:</h3>

<table border="0">
    <tr>
        <td valign="top"><tt>X</tt> </td>
        <td valign="top">A type that is a model of <font size="2"
        face="Courier New">jtime_c</font></td>
    </tr>
    <tr>
        <td valign="top"><tt>a</tt> </td>
        <td valign="top">Object of type <tt>X</tt> </td>
    </tr>
</table>

<h3>Public Members:</h3>

<table border="1">
    <tr>
        <th>Name </th>
        <th>Expression </th>
        <th>Precondition </th>
        <th>Semantics </th>
        <th>Postcondition </th>
    </tr>
    <tr>
        <td valign="top">Default constructor </td>
        <td valign="top"><pre>X a()</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Default Constructor.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Copy constructor </td>
        <td valign="top"><pre>X a(const X &amp;b)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Copy construct a <font size="2"
        face="Courier New">jtime_c</font>.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Construct from SQL timestamp </td>
        <td valign="top"><pre>X a(const TIMESTAMP_STRUCT &amp;b)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Construct from a <font size="2"
        face="Courier New">TIMESTAMP_STRUCT</font>.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Construct from <font size="2"
        face="Courier New">jtime_t</font></td>
        <td valign="top"><pre>X a(const jtime_t &amp;b)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Construct from a <font size="2"
        face="Courier New">jtime_t</font>.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Assignment operators</td>
        <td valign="top"><pre>X&amp; operator=(const X&amp;b)</pre>
        <pre>X&amp; operator=(const TIMESTAMP_STRUCT &amp;b)</pre>
        <pre>X&amp; operator=(const jtime_t &amp;b)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Assignment of a date.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Comparison operators</td>
        <td valign="top"><font size="2" face="Courier New">friend
        bool operator&lt;(const jtime_c &amp;lhs, const jtime_c
        &amp;rhs)</font><p><font size="2" face="Courier New">friend
        bool operator&lt;(const jtime_c &amp;lhs, const jtime_c
        &amp;rhs)</font></p>
        <p><font size="2" face="Courier New">friend bool
        operator&gt;(const jtime_c &amp;lhs, const jtime_c
        &amp;rhs)</font></p>
        <p><font size="2" face="Courier New">friend bool
        operator&lt;=(const jtime_c &amp;lhs, const jtime_c
        &amp;rhs)</font></p>
        <p><font size="2" face="Courier New">friend bool
        operator&gt;=(const jtime_c &amp;lhs, const jtime_c
        &amp;rhs)</font></p>
        <p><font size="2" face="Courier New">friend bool operator!=(const
        jtime_c &amp;lhs, const jtime_c &amp;rhs)</font></p>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Compare two dates. Note that these are
        friends.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Stream operator</td>
        <td valign="top"><pre>friend ostream &amp;operator&lt;&lt;(ostream &amp;o, const jtime_c &amp;ts)</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Stream out the date to <font size="2"
        face="Courier New">o</font>. Note that this is a friend.</td>
        <td valign="top">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top">Conversion operators</td>
        <td valign="top"><pre>operator jtime_t() const</pre>
        <pre>operator TIMESTAMP_STRUCT() const</pre>
        </td>
        <td valign="top">&nbsp; </td>
        <td valign="top">Converts the object into the appropriate
        date type.</td>
        <td valign="top">&nbsp;</td>
    </tr>
</table>

<h3>Global Functions</h3>

<p>&nbsp;</p>

<table border="1">
    <tr>
        <th>Description</th>
        <th>Expression </th>
    </tr>
    <tr>
        <td valign="top">Returns current local time including
        seconds</td>
        <td valign="top"><pre>jtime_t Now()</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Returns current local time rounded down
        to midnight of that day. (i.e. the current day).</td>
        <td valign="top"><pre>jtime_t Today()</pre>
        </td>
    </tr>
    <tr>
        <td valign="top"><font size="3">Convert from an ODBC
        timestamp to </font><font size="2" face="Courier New">jtime_t</font></td>
        <td valign="top"><pre>RETCODE Timestamp2Jtime(const timestamp_t *tst, jtime_t *jtime );</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Convert from a <font size="2"
        face="Courier New">jtime_t </font><font size="3">to an
        ODBC timestamp.</font></td>
        <td valign="top"><pre>RETCODE Jtime2Timestamp(jtime_t jtime, timestamp_t *tst)&amp; operator=(const X&amp;b)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Convert a date in day/month/year format
        to a <font size="2" face="Courier New">jtime_t</font></td>
        <td valign="top"><font size="2" face="Courier New">RETCODE
        julday(int day, int month, int year, jtime_t *jtime)</font></td>
    </tr>
    <tr>
        <td valign="top">Convert from <font size="2"
        face="Courier New">jtime_t </font>to a <font size="2"
        face="Courier New">jtime_tm</font> structure.</td>
        <td valign="top"><pre>RETCODE unjultime(jtime_t jtime, jtime_tm *time)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Convert a <font size="2"
        face="Courier New">jtime_tm</font> structure into a <font
        size="2" face="Courier New">jtime_t</font></td>
        <td valign="top"><pre>RETCODE jultime(const jtime_tm *time, jtime_t *jtime)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Add the time in the <font size="2"
        face="Courier New">jtime_tm</font> structure to the date
        held by <font size="2" face="Courier New">oldtime</font>.</td>
        <td valign="top"><font size="2" face="Courier New">RETCODE
        addtime(jtime_t oldtime, jtime_tm add, jtime_t *newtime)</font></td>
    </tr>
    <tr>
        <td valign="top">Add the number of seconds to the date
        passed in</td>
        <td valign="top"><pre>jtime_t addsecs(jtime_t oldtime, int secs)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Add the number of hours to the date
        passed in</td>
        <td valign="top"><pre>jtime_t addhours(jtime_t oldtime, int hours)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Add the number of days to the date
        passed in</td>
        <td valign="top"><pre>jtime_t adddays(jtime_t oldtime, int days)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Add the number of months to the date
        passed in</td>
        <td valign="top"><pre>jtime_t addmonths(jtime_t oldtime, int months)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Return the date as a C string down to
        the day in the formt 'MON-DD-YYYY HH:MM:SS'</td>
        <td valign="top"><pre>char *jul2str(jtime_t juldate)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Return the time as a C string down to
        the second in the format 'MON-DD-YYYY HH:MM:SS'. If HH:MM:SS
        is midnight this will be truncated down to a day format. </td>
        <td valign="top"><pre>char *jul2strtm(jtime_t jtime)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Convert the date into a SQL date string</td>
        <td valign="top"><pre>void jul2SQLtm(jtime_t jultime, char *szSQLtm)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top"><font size="3">Convert the string date
        in the format 'MON-DD-YYYY' to a Julian date</font></td>
        <td valign="top"><pre>RETCODE str2jultm(char *szDt, jtime_t *jtime)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Find the difference in the appropriate
        time units</td>
        <td valign="top"><pre>double diffdays(jtime_t date1, jtime_t date2)</pre>
        <pre>double diffhours(jtime_t date1, jtime_t date2)</pre>
        <pre>double diffsecs(jtime_t date1, jtime_t date2)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Find the end of the month, week, or day
        passed in.</td>
        <td valign="top"><pre>jtime_t eomonth(jtime_t oldtime)</pre>
        <pre>jtime_t eoweek(jtime_t oldtime)</pre>
        <pre>jtime_t eoday(jtime_t oldtime)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Find the beginning of the month, week,
        or day passed in. (Beginning of a day is at midnight).</td>
        <td valign="top"><pre>jtime_t beginmonth(jtime_t oldtime)</pre>
        <pre>jtime_t beginweek(jtime_t oldtime)</pre>
        <pre>jtime_t beginday(jtime_t oldtime)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Return the number of days in the month
        of the year</td>
        <td valign="top"><pre>int month_days(int year, int month)</pre>
        </td>
    </tr>
   <tr>
        <td valign="top">Given a particular date return the what week in the current 
	month this represents, i.e. first week, second week, etc.
	Weeks are assumed to start on Sunday and end on Saturday.</td>
        <td valign="top"><pre>int monthweek(jtime_t jtime)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Return the year, or month of the
        week of the passed in date.</td>
        <td valign="top"><pre>int year(jtime_t oldtime)</pre>
        <pre>int month(jtime_t oldtime)</pre>
        </td>
    </tr>
    <tr>
        <td valign="top">Return the maximum or minimum of the two
        dates passed in.</td>
        <td valign="top"><pre>jtime_t maxtime(jtime_t a, jtime_t b)</pre>
        <pre>jtime_t mintime(jtime_t a, jtime_t b)</pre>
        </td>
    </tr>
</table>

<h3>See also</h3>

<p>None. </p>


<hr>

<p><a href="index.htm"><img src="dtl_home.gif" alt="[DTL Home]"
width="54" height="54"></a> <br>
</p>

<p>Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -