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

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

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><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.73.2"><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.9 (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"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"><link rel="index" href="ix09.html" title="Index of new symbols in 2.14"><link rel="index" href="ix10.html" title="Index of new symbols in 2.16"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" 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><tr><td colspan="5" class="shortcuts"><nobr><a href="#id3033207" class="shortcut">Top</a>                  &#160;|&#160;                  <a href="#id3034794" class="shortcut">Description</a></nobr></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><a name="id3033207"></a><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 class="link" href="glib-Date-and-Time-Functions.html#G-USEC-PER-SEC:CAPS">G_USEC_PER_SEC</a>                    <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a>;void                <a class="link" href="glib-Date-and-Time-Functions.html#g-get-current-time">g_get_current_time</a>                  (<a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *result);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-usleep">g_usleep</a>                            (<a class="link" href="glib-Basic-Types.html#gulong">gulong</a> microseconds);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-time-val-add">g_time_val_add</a>                      (<a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *time_,                                                         <a class="link" href="glib-Basic-Types.html#glong">glong</a> microseconds);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-time-val-from-iso8601">g_time_val_from_iso8601</a>             (const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *iso_date,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *time_);<a class="link" href="glib-Basic-Types.html#gchar">gchar</a>*              <a class="link" href="glib-Date-and-Time-Functions.html#g-time-val-to-iso8601">g_time_val_to_iso8601</a>               (<a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *time_);                    <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a>;typedef             <a class="link" href="glib-Date-and-Time-Functions.html#GTime">GTime</a>;enum                <a class="link" href="glib-Date-and-Time-Functions.html#GDateDMY">GDateDMY</a>;typedef             <a class="link" href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a>;enum                <a class="link" href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a>;typedef             <a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a>;enum                <a class="link" href="glib-Date-and-Time-Functions.html#GDateWeekday">GDateWeekday</a>;#define             <a class="link" href="glib-Date-and-Time-Functions.html#G-DATE-BAD-DAY:CAPS">G_DATE_BAD_DAY</a>#define             <a class="link" href="glib-Date-and-Time-Functions.html#G-DATE-BAD-JULIAN:CAPS">G_DATE_BAD_JULIAN</a>#define             <a class="link" href="glib-Date-and-Time-Functions.html#G-DATE-BAD-YEAR:CAPS">G_DATE_BAD_YEAR</a><a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a>*              <a class="link" href="glib-Date-and-Time-Functions.html#g-date-new">g_date_new</a>                          (void);<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a>*              <a class="link" href="glib-Date-and-Time-Functions.html#g-date-new-dmy">g_date_new_dmy</a>                      (<a class="link" href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a>*              <a class="link" href="glib-Date-and-Time-Functions.html#g-date-new-julian">g_date_new_julian</a>                   (<a class="link" href="glib-Basic-Types.html#guint32">guint32</a> julian_day);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-clear">g_date_clear</a>                        (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> n_dates);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-free">g_date_free</a>                         (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-day">g_date_set_day</a>                      (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-month">g_date_set_month</a>                    (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-year">g_date_set_year</a>                     (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-dmy">g_date_set_dmy</a>                      (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> y);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-julian">g_date_set_julian</a>                   (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Basic-Types.html#guint32">guint32</a> julian_date);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-time">g_date_set_time</a>                     (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GTime">GTime</a> time_);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-time-t">g_date_set_time_t</a>                   (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         time_t timet);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-time-val">g_date_set_time_val</a>                 (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *timeval);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-set-parse">g_date_set_parse</a>                    (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *str);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-add-days">g_date_add_days</a>                     (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> n_days);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-subtract-days">g_date_subtract_days</a>                (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> n_days);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-add-months">g_date_add_months</a>                   (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> n_months);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-subtract-months">g_date_subtract_months</a>              (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> n_months);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-add-years">g_date_add_years</a>                    (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> n_years);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-subtract-years">g_date_subtract_years</a>               (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         <a class="link" href="glib-Basic-Types.html#guint">guint</a> n_years);<a class="link" href="glib-Basic-Types.html#gint">gint</a>                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-days-between">g_date_days_between</a>                 (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date1,                                                         const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date2);<a class="link" href="glib-Basic-Types.html#gint">gint</a>                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-compare">g_date_compare</a>                      (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *lhs,                                                         const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *rhs);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-clamp">g_date_clamp</a>                        (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *min_date,                                                         const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *max_date);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-order">g_date_order</a>                        (<a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date1,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date2);<a class="link" href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-day">g_date_get_day</a>                      (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a>          <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-month">g_date_get_month</a>                    (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a>           <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-year">g_date_get_year</a>                     (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#guint32">guint32</a>             <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-julian">g_date_get_julian</a>                   (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Date-and-Time-Functions.html#GDateWeekday">GDateWeekday</a>        <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-weekday">g_date_get_weekday</a>                  (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#guint">guint</a>               <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-day-of-year">g_date_get_day_of_year</a>              (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#guint8">guint8</a>              <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-days-in-month">g_date_get_days_in_month</a>            (<a class="link" href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-is-first-of-month">g_date_is_first_of_month</a>            (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-is-last-of-month">g_date_is_last_of_month</a>             (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-is-leap-year">g_date_is_leap_year</a>                 (<a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a class="link" href="glib-Basic-Types.html#guint">guint</a>               <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-monday-week-of-year">g_date_get_monday_week_of_year</a>      (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#guint8">guint8</a>              <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-monday-weeks-in-year">g_date_get_monday_weeks_in_year</a>     (<a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a class="link" href="glib-Basic-Types.html#guint">guint</a>               <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-sunday-week-of-year">g_date_get_sunday_week_of_year</a>      (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#guint8">guint8</a>              <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-sunday-weeks-in-year">g_date_get_sunday_weeks_in_year</a>     (<a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a class="link" href="glib-Basic-Types.html#guint">guint</a>               <a class="link" href="glib-Date-and-Time-Functions.html#g-date-get-iso8601-week-of-year">g_date_get_iso8601_week_of_year</a>     (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#gsize">gsize</a>               <a class="link" href="glib-Date-and-Time-Functions.html#g-date-strftime">g_date_strftime</a>                     (<a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *s,                                                         <a class="link" href="glib-Basic-Types.html#gsize">gsize</a> slen,                                                         const <a class="link" href="glib-Basic-Types.html#gchar">gchar</a> *format,                                                         const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);void                <a class="link" href="glib-Date-and-Time-Functions.html#g-date-to-struct-tm">g_date_to_struct_tm</a>                 (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date,                                                         struct tm *tm);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-valid">g_date_valid</a>                        (const <a class="link" href="glib-Date-and-Time-Functions.html#GDate">GDate</a> *date);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-valid-day">g_date_valid_day</a>                    (<a class="link" href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-valid-month">g_date_valid_month</a>                  (<a class="link" href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-valid-year">g_date_valid_year</a>                   (<a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-valid-dmy">g_date_valid_dmy</a>                    (<a class="link" href="glib-Date-and-Time-Functions.html#GDateDay">GDateDay</a> day,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateMonth">GDateMonth</a> month,                                                         <a class="link" href="glib-Date-and-Time-Functions.html#GDateYear">GDateYear</a> year);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-valid-julian">g_date_valid_julian</a>                 (<a class="link" href="glib-Basic-Types.html#guint32">guint32</a> julian_date);<a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="glib-Date-and-Time-Functions.html#g-date-valid-weekday">g_date_valid_weekday</a>                (<a class="link" href="glib-Date-and-Time-Functions.html#GDateWeekday">GDateWeekday</a> weekday);</pre></div><div class="refsect1" lang="en"><a name="id3034794"></a><h2>Description</h2><p>The <a class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" href="glib-Date-and-Time-Functions.html#g-date-valid"><code class="function">g_date_valid()</code></a> predicate. <a class="link" 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 class="link" 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 class="link" 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 class="link" 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 class="link" href="glib-Date-and-Time-Functions.html#GTime"><span class="type">GTime</span></a> typedef and a <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a> struct which represents a more precise time (with microseconds). You can request the current time as a <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a> with <a class="link" 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="id3035050"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3035060"></a><h3><a name="G-USEC-PER-SEC:CAPS"></a>G_USEC_PER_SEC</h3><a class="indexterm" name="id3035072"></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>

⌨️ 快捷键说明

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