Rover12421's Blog

The End.

时间转换—-整数型(s)转tm类型

可用于java的整形时间转c的tm类型时间。java的时间精确度是ms。

-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-–-—-

lhtime.h

#ifndef LHTIME_H
#define LHTIME_H

//
/ 时间处理函数                                                         /
/ lh_tm结构来自glibc中的tm结构                                         /
/ lhtime_Covent函数摘自glibc中的__offtime函数                          /
/ 精确度为s,而不是ms                                                  /
/
/

#define    SECS_PER_HOUR    (60 * 60)
#define    SECS_PER_DAY    (SECS_PER_HOUR * 24)

typedef struct lh_tm
{
    int tm_sec;     / seconds after the minute - [0,59] /
    int tm_min;     / minutes after the hour - [0,59] /
    int tm_hour;    / hours since midnight - [0,23] /
    int tm_mday;    / day of the month - [1,31] /
    int tm_mon;     / months since January - [0,11] /
    int tm_year;    / years since 1900 /
    int tm_wday;    / days since Sunday - [0,6] /
    int tm_yday;    / days since January 1 - [0,365] /
    int tm_isdst;   / daylight savings time flag /
}lh_tm;

# define __isleap(year)    \
    ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))

/
    设置时区,默认为东八区,+8
*/
void lhtime_setTimeZone(int16 zone);

/
    从秒数创建lh_tm结构
/
lh_tm
lhtime_create(int32 ms);

/
    释放lh_tm结构
*/
#define lhtime_delete(lhtime)    FREE(lhtime)

/
    获取平常显示的年份
/
#define lhtime_delete_getYear(lhtime)   (1900+((lh_tm
)(lhtime))->tm_year)

/
    获取平常显示的月份
/
#define lhtime_delete_getMon(lhtime)   (1+((lh_tm
)(lhtime))->tm_mon)

#endif  / LHTIME_H /

lhtime.c

<blockquote>
  <div style="font-family: &#39;[object HTMLOptionElement]&#39;, consolas, &#39;Lucida Console&#39;, &#39;Courier New&#39;; color: rgb(0,0,0)" class="source">
    <span style="color: rgb(0,128,128)">#include "lhtime.h"</span> </p> <p>
      <span style="color: rgb(0,0,128); font-weight: bold">const</span> <span style="color: rgb(0,0,128); font-weight: bold">unsigned</span> <span style="color: rgb(0,0,128); font-weight: bold">short</span> <span style="color: rgb(0,0,128); font-weight: bold">int</span> <span style="color: rgb(0,0,0)">__mon_yday</span><span style="color: rgb(0,0,0)">[</span><span style="color: rgb(0,0,255)">2</span><span style="color: rgb(0,0,0)">][</span><span style="color: rgb(0,0,255)">13</span><span style="color: rgb(0,0,0)">]</span> <span style="color: rgb(0,0,0)">=</span> <br /><span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160; <span style="font-style: italic; color: rgb(0,136,0)">/* Normal years.&#160; */</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">{</span> <span style="color: rgb(0,0,255)"></span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">31</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">59</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">90</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">120</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">151</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">181</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">212</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">243</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">273</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">304</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">334</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">365</span> <span style="color: rgb(0,0,0)">},</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="font-style: italic; color: rgb(0,136,0)">/* Leap years.&#160; */</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">{</span> <span style="color: rgb(0,0,255)"></span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">31</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">60</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">91</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">121</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">152</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">182</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">213</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">244</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">274</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">305</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">335</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,255)">366</span> <span style="color: rgb(0,0,0)">}</span> <br /><span style="color: rgb(0,0,0)">};</span>
    </p>

    <p>
      <span style="color: rgb(0,0,0)">int16</span> <span style="color: rgb(0,0,0)">time_zone_offset</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,255)">8</span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)">SECS_PER_HOUR</span>;
    </p>

    <p>
      <span style="font-style: italic; color: rgb(0,136,0)">/* Compute the `struct tm' representation of *T,</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">&#160;&#160; offset OFFSET seconds east of UTC,</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">&#160;&#160; and store year, yday, mon, mday, wday, hour, min, sec into *TP.</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">&#160;&#160; Return nonzero if successful.&#160; */</span> <br /><span style="color: rgb(0,0,0)">int8</span> <span style="color: rgb(0,0,0)">lhtime_Covent</span> (<span style="color: rgb(0,0,128); font-weight: bold">const</span> <span style="color: rgb(0,0,0)">int32</span><span style="color: rgb(0,0,0)">*</span> <span style="color: rgb(0,0,0)">t</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,128); font-weight: bold">long</span> <span style="color: rgb(0,0,128); font-weight: bold">int</span> <span style="color: rgb(0,0,0)">offset</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,0)">lh_tm</span><span style="color: rgb(0,0,0)">*</span> <span style="color: rgb(0,0,0)">tp</span>) <br /><span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">long</span> <span style="color: rgb(0,0,128); font-weight: bold">int</span> <span style="color: rgb(0,0,0)">days</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,0)">rem</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,0)">y</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">const</span> <span style="color: rgb(0,0,128); font-weight: bold">unsigned</span> <span style="color: rgb(0,0,128); font-weight: bold">short</span> <span style="color: rgb(0,0,128); font-weight: bold">int</span> <span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)">ip</span>; <br />&#160;&#160;&#160; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)">t</span> <span style="color: rgb(0,0,0)">/</span> <span style="color: rgb(0,0,0)">SECS_PER_DAY</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)">t</span> <span style="color: rgb(0,0,0)">%</span> <span style="color: rgb(0,0,0)">SECS_PER_DAY</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">+=</span> <span style="color: rgb(0,0,0)">offset</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">while</span> (<span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)"><</span> <span style="color: rgb(0,0,255)"></span>) <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">+=</span> <span style="color: rgb(0,0,0)">SECS_PER_DAY</span>; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">--</span><span style="color: rgb(0,0,0)">days</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">}</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">while</span> (<span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">>=</span> <span style="color: rgb(0,0,0)">SECS_PER_DAY</span>) <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">-=</span> <span style="color: rgb(0,0,0)">SECS_PER_DAY</span>; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">++</span><span style="color: rgb(0,0,0)">days</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">}</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_hour</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">/</span> <span style="color: rgb(0,0,0)">SECS_PER_HOUR</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">%=</span> <span style="color: rgb(0,0,0)">SECS_PER_HOUR</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_min</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">/</span> <span style="color: rgb(0,0,255)">60</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_sec</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">rem</span> <span style="color: rgb(0,0,0)">%</span> <span style="color: rgb(0,0,255)">60</span>; <br />&#160;&#160;&#160; <span style="font-style: italic; color: rgb(0,136,0)">/* January 1, 1970 was a Thursday.&#160; */</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_wday</span> <span style="color: rgb(0,0,0)">=</span> (<span style="color: rgb(0,0,255)">4</span> <span style="color: rgb(0,0,0)">+</span> <span style="color: rgb(0,0,0)">days</span>) <span style="color: rgb(0,0,0)">%</span> <span style="color: rgb(0,0,255)">7</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">if</span> (<span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_wday</span> <span style="color: rgb(0,0,0)"><</span> <span style="color: rgb(0,0,255)"></span>) <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_wday</span> <span style="color: rgb(0,0,0)">+=</span> <span style="color: rgb(0,0,255)">7</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">y</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,255)">1970</span>; <br />&#160;&#160;&#160; <br /><span style="color: rgb(0,128,128)">#define DIV(a, b) ((a) / (b) - ((a) % (b) < 0))</span> <br /><span style="color: rgb(0,128,128)">#define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))</span> <br />&#160;&#160;&#160; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">while</span> (<span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)"><</span> <span style="color: rgb(0,0,255)"></span> || <span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)">>=</span> (<span style="color: rgb(0,0,0)">__isleap</span> (<span style="color: rgb(0,0,0)">y</span>) <span style="color: rgb(0,0,0)">?</span> <span style="color: rgb(0,0,255)">366</span> <span style="color: rgb(0,0,0)">:</span> <span style="color: rgb(0,0,255)">365</span>)) <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="font-style: italic; color: rgb(0,136,0)">/* Guess a corrected year, assuming 365 days per year.&#160; */</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">long</span> <span style="color: rgb(0,0,128); font-weight: bold">int</span> <span style="color: rgb(0,0,0)">yg</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">y</span> <span style="color: rgb(0,0,0)">+</span> <span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)">/</span> <span style="color: rgb(0,0,255)">365</span> <span style="color: rgb(0,0,0)">-</span> (<span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)">%</span> <span style="color: rgb(0,0,255)">365</span> <span style="color: rgb(0,0,0)"><</span> <span style="color: rgb(0,0,255)"></span>); <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="font-style: italic; color: rgb(0,136,0)">/* Adjust DAYS and Y to match the guessed year.&#160; */</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)">-=</span> ((<span style="color: rgb(0,0,0)">yg</span> <span style="color: rgb(0,0,0)">-</span> <span style="color: rgb(0,0,0)">y</span>) <span style="color: rgb(0,0,0)">*</span> <span style="color: rgb(0,0,255)">365</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">+</span> <span style="color: rgb(0,0,0)">LEAPS_THRU_END_OF</span> (<span style="color: rgb(0,0,0)">yg</span> <span style="color: rgb(0,0,0)">-</span> <span style="color: rgb(0,0,255)">1</span>) <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">-</span> <span style="color: rgb(0,0,0)">LEAPS_THRU_END_OF</span> (<span style="color: rgb(0,0,0)">y</span> <span style="color: rgb(0,0,0)">-</span> <span style="color: rgb(0,0,255)">1</span>)); <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">y</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">yg</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">}</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_year</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">y</span> <span style="color: rgb(0,0,0)">-</span> <span style="color: rgb(0,0,255)">1900</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">if</span> (<span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_year</span> <span style="color: rgb(0,0,0)">!=</span> <span style="color: rgb(0,0,0)">y</span> <span style="color: rgb(0,0,0)">-</span> <span style="color: rgb(0,0,255)">1900</span>) <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="font-style: italic; color: rgb(0,136,0)">/* The year cannot be represented due to overflow.&#160; */</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="font-style: italic; color: rgb(0,136,0)">//__set_errno (EOVERFLOW);</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">return</span> <span style="color: rgb(0,0,0)">FALSE</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">}</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_yday</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">days</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">ip</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">__mon_yday</span><span style="color: rgb(0,0,0)">[</span><span style="color: rgb(0,0,0)">__isleap</span>(<span style="color: rgb(0,0,0)">y</span><span style="color: rgb(0,0,0)">)];</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">for</span> (<span style="color: rgb(0,0,0)">y</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,255)">11</span>; <span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)"><</span> (<span style="color: rgb(0,0,128); font-weight: bold">long</span> <span style="color: rgb(0,0,128); font-weight: bold">int</span>) <span style="color: rgb(0,0,0)">ip</span><span style="color: rgb(0,0,0)">[</span><span style="color: rgb(0,0,0)">y</span><span style="color: rgb(0,0,0)">];</span> <span style="color: rgb(0,0,0)">--</span><span style="color: rgb(0,0,0)">y</span>) <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">continue</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)">-=</span> <span style="color: rgb(0,0,0)">ip</span><span style="color: rgb(0,0,0)">[</span><span style="color: rgb(0,0,0)">y</span><span style="color: rgb(0,0,0)">];</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_mon</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">y</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">tp</span><span style="color: rgb(0,0,0)">-></span><span style="color: rgb(0,0,0)">tm_mday</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">days</span> <span style="color: rgb(0,0,0)">+</span> <span style="color: rgb(0,0,255)">1</span>; <br />&#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">return</span> <span style="color: rgb(0,0,0)">TRUE</span>; <br /><span style="color: rgb(0,0,0)">}</span>
    </p>

    <p>
      <span style="font-style: italic; color: rgb(0,136,0)">/*</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">*&#160;&#160;&#160; 设置时区,默认为东八区,+8</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">*/</span> <br /><span style="color: rgb(0,0,128); font-weight: bold">void</span> <span style="color: rgb(0,0,0)">lhtime_setTimeZone</span>(<span style="color: rgb(0,0,0)">int16</span> <span style="color: rgb(0,0,0)">zone</span>) <br /><span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">time_zone_offset</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">zone</span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)">SECS_PER_HOUR</span>; <br /><span style="color: rgb(0,0,0)">}</span>
    </p>

    <p>
      <span style="font-style: italic; color: rgb(0,136,0)">/*</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">*&#160;&#160;&#160; 从秒数创建lh_tm结构</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">*/</span> <br /><span style="color: rgb(0,0,0)">lh_tm</span><span style="color: rgb(0,0,0)">*</span> <span style="color: rgb(0,0,0)">lhtime_create</span>(<span style="color: rgb(0,0,0)">int32</span> <span style="color: rgb(0,0,0)">ms</span>) <br /><span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">lh_tm</span><span style="color: rgb(0,0,0)">*</span> <span style="color: rgb(0,0,0)">lhtime</span> <span style="color: rgb(0,0,0)">=</span> <span style="color: rgb(0,0,0)">NULL</span>;
    </p>

    <p>
      &#160;&#160;&#160; <span style="color: rgb(0,0,0)">MALLOC</span>(<span style="color: rgb(0,0,0)">&</span><span style="color: rgb(0,0,0)">lhtime</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,128); font-weight: bold">sizeof</span>(<span style="color: rgb(0,0,0)">lh_tm</span>));
    </p>

    <p>
      &#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">if</span> (<span style="color: rgb(0,0,0)">lhtime_Covent</span>(<span style="color: rgb(0,0,0)">&</span><span style="color: rgb(0,0,0)">ms</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,0)">time_zone_offset</span><span style="color: rgb(0,0,0)">,</span> <span style="color: rgb(0,0,0)">lhtime</span>) <span style="color: rgb(0,0,0)">!=</span> <span style="color: rgb(0,0,0)">TRUE</span>) <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">{</span> <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: rgb(0,0,0)">lhtime_delete</span>(<span style="color: rgb(0,0,0)">&</span><span style="color: rgb(0,0,0)">lhtime</span>); <br />&#160;&#160;&#160; <span style="color: rgb(0,0,0)">}</span>
    </p>

    <p>
      <span style="font-style: italic; color: rgb(0,136,0)">//&#160;&#160;&#160;&#160; if (lhtime != NULL)</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">//&#160;&#160;&#160;&#160; {</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">//&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PRINT("%d = %d year, %d mon, %d day, %d hour, %d min, %d sec", ms, 1900 + lhtime->tm_year, 1+lhtime->tm_mon, lhtime->tm_mday, lhtime->tm_hour, lhtime->tm_min, lhtime->tm_sec);</span> <br /><span style="font-style: italic; color: rgb(0,136,0)">//&#160;&#160;&#160;&#160; }</span>
    </p>

    <p>
      &#160;&#160;&#160; <span style="color: rgb(0,0,128); font-weight: bold">return</span> <span style="color: rgb(0,0,0)">lhtime</span>; <br /><span style="color: rgb(0,0,0)">}</span> </div> </blockquote>

Comments