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

📄 glib-date-and-time-functions.html

📁 glid编写实例
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<html xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Date and Time Functions</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.0"><link rel="start" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-utilities.html" title="GLib Utilities"><link rel="prev" href="glib-I18N.html" title="Internationalization"><link rel="next" href="glib-Random-Numbers.html" title="Random Numbers"><meta name="generator" content="GTK-Doc V1.4 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-I18N.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-Random-Numbers.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-Date-and-Time-Functions"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><span class="refentrytitle">Date and Time Functions</span></h2><p>Date and Time Functions &#8212; calendrical calculations and miscellaneous time stuff.</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include &lt;glib.h&gt;#define     <a href="glib-Date-and-Time-Functions.html#G-USEC-PER-SEC:CAPS">G_USEC_PER_SEC</a>            <a href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a>;void        <a href="glib-Date-and-Time-Functions.html#g-get-current-time">g_get_current_time</a>              (<a href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *result);void        <a href="glib-Date-and-Time-Functions.html#g-usleep">g_usleep</a>                        (<a href="glib-Basic-Types.html#gulong">gulong</a> microseconds);void        <a href="glib-Date-and-Time-Functions.html#g-time-val-add">g_time_val_add</a>                  (<a href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *time_,                                             <a href="glib-Basic-Types.html#glong">glong</a> microseconds);            <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a>;typedef     <a href="glib-Date-and-Time-Functions.html#GTime">GTime</a>;enum        <a href="glib-Date-and-Time-Functions.html#GDateDMY">GDateDMY</a>;typedef     <a href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a>;enum        <a href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a>;typedef     <a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a>;enum        <a href="glib-Date-and-Time-Functions.html#GDateWeekday">GDateWeekday</a>;#define     <a href="glib-Date-and-Time-Functions.html#G-DATE-BAD-DAY:CAPS">G_DATE_BAD_DAY</a>#define     <a href="glib-Date-and-Time-Functions.html#G-DATE-BAD-JULIAN:CAPS">G_DATE_BAD_JULIAN</a>#define     <a href="glib-Date-and-Time-Functions.html#G-DATE-BAD-YEAR:CAPS">G_DATE_BAD_YEAR</a><a href="glib-Date-and-Time-Functions.html#GDate">GDate</a>*      <a href="glib-Date-and-Time-Functions.html#g-date-new">g_date_new</a>                      (void);<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a>*      <a href="glib-Date-and-Time-Functions.html#g-date-new-dmy">g_date_new_dmy</a>                  (<a href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day,                                             <a href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month,                                             <a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a>*      <a href="glib-Date-and-Time-Functions.html#g-date-new-julian">g_date_new_julian</a>               (<a href="glib-Basic-Types.html#guint32">guint32</a> julian_day);void        <a href="glib-Date-and-Time-Functions.html#g-date-clear">g_date_clear</a>                    (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Basic-Types.html#guint">guint</a> n_dates);void        <a href="glib-Date-and-Time-Functions.html#g-date-free">g_date_free</a>                     (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);void        <a href="glib-Date-and-Time-Functions.html#g-date-set-day">g_date_set_day</a>                  (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day);void        <a href="glib-Date-and-Time-Functions.html#g-date-set-month">g_date_set_month</a>                (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month);void        <a href="glib-Date-and-Time-Functions.html#g-date-set-year">g_date_set_year</a>                 (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);void        <a href="glib-Date-and-Time-Functions.html#g-date-set-dmy">g_date_set_dmy</a>                  (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day,                                             <a href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month,                                             <a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> y);void        <a href="glib-Date-and-Time-Functions.html#g-date-set-julian">g_date_set_julian</a>               (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Basic-Types.html#guint32">guint32</a> julian_date);void        <a href="glib-Date-and-Time-Functions.html#g-date-set-time">g_date_set_time</a>                 (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Date-and-Time-Functions.html#GTime">GTime</a> time_);void        <a href="glib-Date-and-Time-Functions.html#g-date-set-parse">g_date_set_parse</a>                (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *str);void        <a href="glib-Date-and-Time-Functions.html#g-date-add-days">g_date_add_days</a>                 (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Basic-Types.html#guint">guint</a> n_days);void        <a href="glib-Date-and-Time-Functions.html#g-date-subtract-days">g_date_subtract_days</a>            (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Basic-Types.html#guint">guint</a> n_days);void        <a href="glib-Date-and-Time-Functions.html#g-date-add-months">g_date_add_months</a>               (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Basic-Types.html#guint">guint</a> n_months);void        <a href="glib-Date-and-Time-Functions.html#g-date-subtract-months">g_date_subtract_months</a>          (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Basic-Types.html#guint">guint</a> n_months);void        <a href="glib-Date-and-Time-Functions.html#g-date-add-years">g_date_add_years</a>                (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Basic-Types.html#guint">guint</a> n_years);void        <a href="glib-Date-and-Time-Functions.html#g-date-subtract-years">g_date_subtract_years</a>           (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             <a href="glib-Basic-Types.html#guint">guint</a> n_years);<a href="glib-Basic-Types.html#gint">gint</a>        <a href="glib-Date-and-Time-Functions.html#g-date-days-between">g_date_days_between</a>             (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date1,                                             const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date2);<a href="glib-Basic-Types.html#gint">gint</a>        <a href="glib-Date-and-Time-Functions.html#g-date-compare">g_date_compare</a>                  (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *lhs,                                             const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *rhs);void        <a href="glib-Date-and-Time-Functions.html#g-date-clamp">g_date_clamp</a>                    (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *min_date,                                             const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *max_date);void        <a href="glib-Date-and-Time-Functions.html#g-date-order">g_date_order</a>                    (<a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date1,                                             <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date2);<a href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a>    <a href="glib-Date-and-Time-Functions.html#g-date-get-day">g_date_get_day</a>                  (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a>  <a href="glib-Date-and-Time-Functions.html#g-date-get-month">g_date_get_month</a>                (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a>   <a href="glib-Date-and-Time-Functions.html#g-date-get-year">g_date_get_year</a>                 (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#guint32">guint32</a>     <a href="glib-Date-and-Time-Functions.html#g-date-get-julian">g_date_get_julian</a>               (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Date-and-Time-Functions.html#GDateWeekday">GDateWeekday</a> <a href="glib-Date-and-Time-Functions.html#g-date-get-weekday">g_date_get_weekday</a>             (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#guint">guint</a>       <a href="glib-Date-and-Time-Functions.html#g-date-get-day-of-year">g_date_get_day_of_year</a>          (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#guint8">guint8</a>      <a href="glib-Date-and-Time-Functions.html#g-date-get-days-in-month">g_date_get_days_in_month</a>        (<a href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month,                                             <a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-is-first-of-month">g_date_is_first_of_month</a>        (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-is-last-of-month">g_date_is_last_of_month</a>         (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-is-leap-year">g_date_is_leap_year</a>             (<a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a href="glib-Basic-Types.html#guint">guint</a>       <a href="glib-Date-and-Time-Functions.html#g-date-get-monday-week-of-year">g_date_get_monday_week_of_year</a>  (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#guint8">guint8</a>      <a href="glib-Date-and-Time-Functions.html#g-date-get-monday-weeks-in-year">g_date_get_monday_weeks_in_year</a> (<a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a href="glib-Basic-Types.html#guint">guint</a>       <a href="glib-Date-and-Time-Functions.html#g-date-get-sunday-week-of-year">g_date_get_sunday_week_of_year</a>  (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#guint8">guint8</a>      <a href="glib-Date-and-Time-Functions.html#g-date-get-sunday-weeks-in-year">g_date_get_sunday_weeks_in_year</a> (<a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a href="glib-Basic-Types.html#guint">guint</a>       <a href="glib-Date-and-Time-Functions.html#g-date-get-iso8601-week-of-year">g_date_get_iso8601_week_of_year</a> (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#gsize">gsize</a>       <a href="glib-Date-and-Time-Functions.html#g-date-strftime">g_date_strftime</a>                 (<a href="glib-Basic-Types.html#gchar">gchar</a> *s,                                             <a href="glib-Basic-Types.html#gsize">gsize</a> slen,                                             const <a href="glib-Basic-Types.html#gchar">gchar</a> *format,                                             const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);void        <a href="glib-Date-and-Time-Functions.html#g-date-to-struct-tm">g_date_to_struct_tm</a>             (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                             struct tm *tm);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-valid">g_date_valid</a>                    (const <a href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-valid-day">g_date_valid_day</a>                (<a href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-valid-month">g_date_valid_month</a>              (<a href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-valid-year">g_date_valid_year</a>               (<a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-valid-dmy">g_date_valid_dmy</a>                (<a href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day,                                             <a href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month,                                             <a href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-valid-julian">g_date_valid_julian</a>             (<a href="glib-Basic-Types.html#guint32">guint32</a> julian_date);<a href="glib-Basic-Types.html#gboolean">gboolean</a>    <a href="glib-Date-and-Time-Functions.html#g-date-valid-weekday">g_date_valid_weekday</a>            (<a href="glib-Date-and-Time-Functions.html#GDateWeekday">GDateWeekday</a> weekday);</pre></div><div class="refsect1" lang="en"><a name="id2989699"></a><h2>Description</h2><p>The <a href="glib-Date-and-Time-Functions.html#GDate"><span class="type">GDate</span></a> data structure represents a day between January 1, Year 1,and sometime a few thousand years in the future (right now it will goto the year 65535 or so, but <a href="glib-Date-and-Time-Functions.html#g-date-set-parse"><code class="function">g_date_set_parse()</code></a> only parses up to theyear 8000 or so - just count on "a few thousand"). <a href="glib-Date-and-Time-Functions.html#GDate"><span class="type">GDate</span></a> is meant torepresent everyday dates, not astronomical dates or historical datesor ISO timestamps or the like. It extrapolates the current Gregoriancalendar forward and backward in time; there is no attempt to changethe calendar to match time periods or locations. <a href="glib-Date-and-Time-Functions.html#GDate"><span class="type">GDate</span></a> does not storetime information; it represents a <span class="emphasis"><em>day</em></span>.</p><p>The <a href="glib-Date-and-Time-Functions.html#GDate"><span class="type">GDate</span></a> implementation has several nice features; it is only a64-bit struct, so storing large numbers of dates is very efficient. Itcan keep both a Julian and day-month-year representation of the date,since some calculations are much easier with one representation or theother. A Julian representation is simply a count of days since somefixed day in the past; for <a href="glib-Date-and-Time-Functions.html#GDate"><span class="type">GDate</span></a> the fixed day is January 1, 1 AD.("Julian" dates in the <a href="glib-Date-and-Time-Functions.html#GDate"><span class="type">GDate</span></a> API aren't really Julian dates in thetechnical sense; technically, Julian dates count from the start of theJulian period, Jan 1, 4713 BC).</p><p><a href="glib-Date-and-Time-Functions.html#GDate"><span class="type">GDate</span></a> is simple to use. First you need a "blank" date; you can get adynamically allocated date from <a href="glib-Date-and-Time-Functions.html#g-date-new"><code class="function">g_date_new()</code></a>, or you can declare anautomatic variable or array and initialize it to a sane state bycalling <a href="glib-Date-and-Time-Functions.html#g-date-clear"><code class="function">g_date_clear()</code></a>. A cleared date is sane; it's safe to call<a href="glib-Date-and-Time-Functions.html#g-date-set-dmy"><code class="function">g_date_set_dmy()</code></a> and the other mutator functions to initialize thevalue of a cleared date. However, a cleared date is initially<span class="emphasis"><em>invalid</em></span>, meaning that it doesn't represent a daythat exists. It is undefined to call any of the date calculationroutines on an invalid date. If you obtain a date from a user or otherunpredictable source, you should check its validity with the<a href="glib-Date-and-Time-Functions.html#g-date-valid"><code class="function">g_date_valid()</code></a> predicate. <a href="glib-Date-and-Time-Functions.html#g-date-valid"><code class="function">g_date_valid()</code></a> is also used to check forerrors with <a href="glib-Date-and-Time-Functions.html#g-date-set-parse"><code class="function">g_date_set_parse()</code></a> and other functions that canfail. Dates can be invalidated by calling <a href="glib-Date-and-Time-Functions.html#g-date-clear"><code class="function">g_date_clear()</code></a> again.</p><p><span class="emphasis"><em>It is very important to use the API to access the <a href="glib-Date-and-Time-Functions.html#GDate"><span class="type">GDate</span></a>struct.</em></span> Often only the day-month-year or only the Julianrepresentation is valid. Sometimes neither is valid. Use the API.</p><p>GLib doesn't contain any time-manipulation functions; however, thereis a <a href="glib-Date-and-Time-Functions.html#GTime"><span class="type">GTime</span></a> typedef which is equivalent to <span class="type">time_t</span>, and a <a href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a>struct which represents a more precise time (with microseconds). Youcan request the current time as a <a href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a> with <a href="glib-Date-and-Time-Functions.html#g-get-current-time"><code class="function">g_get_current_time()</code></a>.</p></div><div class="refsect1" lang="en"><a name="id2989955"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2989961"></a><h3><a name="G-USEC-PER-SEC:CAPS"></a>G_USEC_PER_SEC</h3><a class="indexterm" name="id2989971"></a><pre class="programlisting">#define G_USEC_PER_SEC 1000000</pre><p>Number of microseconds in one second (1 million). This macro is provided forcode readability.</p></div><hr><div class="refsect2" lang="en"><a name="id2989988"></a><h3><a name="GTimeVal"></a>GTimeVal</h3><a class="indexterm" name="id2989998"></a><pre class="programlisting">typedef struct {  glong tv_sec;  glong tv_usec;} GTimeVal;</pre><p>Represents a precise time, with seconds and microseconds. Same as the<span class="structname">struct timeval</span> returned by the<code class="function"><code class="function">gettimeofday()</code></code> UNIX call.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><a href="glib-Basic-Types.html#glong">glong</a>&#160;<em class="structfield"><code>tv_sec</code></em>;</span></td><td>seconds.</td></tr><tr><td><span class="term"><a href="glib-Basic-Types.html#glong">glong</a>&#160;<em class="structfield"><code>tv_usec</code></em>;</span></td><td>microseconds.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2990080"></a><h3><a name="g-get-current-time"></a>g_get_current_time ()</h3><a class="indexterm" name="id2990091"></a><pre class="programlisting">void        g_get_current_time              (<a href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *result);</pre><p>Equivalent to the UNIX <code class="function">gettimeofday()</code> function, but portable.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>result</code></em>&#160;:</span></td><td> <a href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a> structure in which to store current time.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2990160"></a><h3><a name="g-usleep"></a>g_usleep ()</h3><a class="indexterm" name="id2990170"></a><pre class="programlisting">void        g_usleep                        (<a href="glib-Basic-Types.html#gulong">gulong</a> microseconds);</pre><p>Pauses the current thread for the given number of microseconds. Thereare 1 million microseconds per second (represented by the<a href="glib-Date-and-Time-Functions.html#G-USEC-PER-SEC:CAPS"><span class="type">G_USEC_PER_SEC</span></a> macro). <a href="glib-Date-and-Time-Functions.html#g-usleep"><code class="function">g_usleep()</code></a> may have limited precision,depending on hardware and operating system; don't rely on the exactlength of the sleep.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>microseconds</code></em>&#160;:</span></td><td>number of microseconds to pause.</td></tr></tbody></table></div></div><hr>

⌨️ 快捷键说明

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