~ubuntu-branches/ubuntu/utopic/glib2.0/utopic

« back to all changes in this revision

Viewing changes to docs/reference/glib/tmpl/date.sgml

Tags: upstream-2.12.12
ImportĀ upstreamĀ versionĀ 2.12.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!-- ##### SECTION Title ##### -->
 
2
Date and Time Functions
 
3
 
 
4
<!-- ##### SECTION Short_Description ##### -->
 
5
calendrical calculations and miscellaneous time stuff.
 
6
 
 
7
<!-- ##### SECTION Long_Description ##### -->
 
8
<para>
 
9
The #GDate data structure represents a day between January 1, Year 1,
 
10
and sometime a few thousand years in the future (right now it will go
 
11
to the year 65535 or so, but g_date_set_parse() only parses up to the
 
12
year 8000 or so - just count on "a few thousand"). #GDate is meant to
 
13
represent everyday dates, not astronomical dates or historical dates
 
14
or ISO timestamps or the like. It extrapolates the current Gregorian
 
15
calendar forward and backward in time; there is no attempt to change
 
16
the calendar to match time periods or locations. #GDate does not store
 
17
time information; it represents a <emphasis>day</emphasis>.
 
18
</para>
 
19
 
 
20
<para>
 
21
The #GDate implementation has several nice features; it is only a
 
22
64-bit struct, so storing large numbers of dates is very efficient. It
 
23
can keep both a Julian and day-month-year representation of the date,
 
24
since some calculations are much easier with one representation or the
 
25
other. A Julian representation is simply a count of days since some
 
26
fixed day in the past; for #GDate the fixed day is January 1, 1 AD.
 
27
("Julian" dates in the #GDate API aren't really Julian dates in the
 
28
technical sense; technically, Julian dates count from the start of the
 
29
Julian period, Jan 1, 4713 BC).
 
30
</para>
 
31
 
 
32
<para>
 
33
#GDate is simple to use. First you need a "blank" date; you can get a
 
34
dynamically allocated date from g_date_new(), or you can declare an
 
35
automatic variable or array and initialize it to a sane state by
 
36
calling g_date_clear(). A cleared date is sane; it's safe to call
 
37
g_date_set_dmy() and the other mutator functions to initialize the
 
38
value of a cleared date. However, a cleared date is initially
 
39
<emphasis>invalid</emphasis>, meaning that it doesn't represent a day
 
40
that exists. It is undefined to call any of the date calculation
 
41
routines on an invalid date. If you obtain a date from a user or other
 
42
unpredictable source, you should check its validity with the
 
43
g_date_valid() predicate. g_date_valid() is also used to check for
 
44
errors with g_date_set_parse() and other functions that can
 
45
fail. Dates can be invalidated by calling g_date_clear() again.
 
46
</para>
 
47
 
 
48
<para>
 
49
<emphasis>It is very important to use the API to access the #GDate
 
50
struct.</emphasis> Often only the day-month-year or only the Julian
 
51
representation is valid. Sometimes neither is valid. Use the API.
 
52
</para>
 
53
 
 
54
<para>
 
55
GLib doesn't contain any time-manipulation functions; however, there
 
56
is a #GTime typedef and a #GTimeVal struct which represents a more 
 
57
precise time (with microseconds). You can request the current time as 
 
58
a #GTimeVal with g_get_current_time().
 
59
</para>
 
60
 
 
61
<!-- ##### SECTION See_Also ##### -->
 
62
<para>
 
63
 
 
64
</para>
 
65
 
 
66
<!-- ##### SECTION Stability_Level ##### -->
 
67
 
 
68
 
 
69
<!-- ##### MACRO G_USEC_PER_SEC ##### -->
 
70
<para>
 
71
Number of microseconds in one second (1 million). This macro is provided for
 
72
code readability.
 
73
</para>
 
74
 
 
75
 
 
76
 
 
77
<!-- ##### STRUCT GTimeVal ##### -->
 
78
<para>
 
79
Represents a precise time, with seconds and microseconds. 
 
80
Similar to the <structname>struct timeval</structname> returned by 
 
81
the <function>gettimeofday()</function> UNIX call.
 
82
</para>
 
83
 
 
84
@tv_sec: seconds.
 
85
@tv_usec: microseconds.
 
86
 
 
87
<!-- ##### FUNCTION g_get_current_time ##### -->
 
88
<para>
 
89
</para>
 
90
 
 
91
@result: 
 
92
 
 
93
 
 
94
<!-- ##### FUNCTION g_usleep ##### -->
 
95
<para>
 
96
Pauses the current thread for the given number of microseconds. There
 
97
are 1 million microseconds per second (represented by the
 
98
#G_USEC_PER_SEC macro). g_usleep() may have limited precision,
 
99
depending on hardware and operating system; don't rely on the exact
 
100
length of the sleep.
 
101
</para>
 
102
 
 
103
@microseconds: number of microseconds to pause.
 
104
 
 
105
 
 
106
<!-- ##### FUNCTION g_time_val_add ##### -->
 
107
<para>
 
108
 
 
109
</para>
 
110
 
 
111
@time_: 
 
112
@microseconds: 
 
113
 
 
114
 
 
115
<!-- ##### FUNCTION g_time_val_from_iso8601 ##### -->
 
116
<para>
 
117
 
 
118
</para>
 
119
 
 
120
@iso_date: 
 
121
@time_: 
 
122
@Returns: 
 
123
 
 
124
 
 
125
<!-- ##### FUNCTION g_time_val_to_iso8601 ##### -->
 
126
<para>
 
127
 
 
128
</para>
 
129
 
 
130
@time_: 
 
131
@Returns: 
 
132
 
 
133
 
 
134
<!-- ##### STRUCT GDate ##### -->
 
135
<para>
 
136
Represents a day between January 1, Year 1 and a few thousand years in
 
137
the future. None of its members should be accessed directly. If the
 
138
<structname>GDate</structname> is obtained from g_date_new(), it will
 
139
be safe to mutate but invalid and thus not safe for calendrical computations.
 
140
If it's declared on the stack, it will contain garbage so must be
 
141
initialized with g_date_clear(). g_date_clear() makes the date invalid
 
142
but sane. An invalid date doesn't represent a day, it's "empty." A
 
143
date becomes valid after you set it to a Julian day or you set a day,
 
144
month, and year.
 
145
</para>
 
146
 
 
147
@julian_days: the Julian representation of the date
 
148
@julian: this bit is set if @julian_days is valid
 
149
@dmy: this is set if @day, @month and @year are valid
 
150
@day: the day of the day-month-year representation of the date, as 
 
151
  a number between 1 and 31
 
152
@month: the day of the day-month-year representation of the date, as 
 
153
  a number between 1 and 12
 
154
@year: the day of the day-month-year representation of the date
 
155
 
 
156
<!-- ##### TYPEDEF GTime ##### -->
 
157
<para>
 
158
Simply a replacement for <type>time_t</type>. It has been deprected
 
159
since it is <emphasis>not</emphasis> equivalent to <type>time_t</type> 
 
160
on 64-bit platforms with a 64-bit <type>time_t</type>. 
 
161
Unrelated to #GTimer.
 
162
</para>
 
163
 
 
164
 
 
165
<para>
 
166
Note that <type>GTime</type> is defined to always be a 32bit integer,
 
167
unlike <type>time_t</type> which may be 64bit on some systems. 
 
168
Therefore, <type>GTime</type> will overflow in the year 2038, and
 
169
you cannot use the address of a <type>GTime</type> variable as argument 
 
170
to the UNIX time() function. Instead, do the following:
 
171
<informalexample>
 
172
<programlisting>
 
173
time_t ttime;
 
174
GTime gtime;
 
175
 
 
176
time (&amp;ttime);
 
177
gtime = (GTime)ttime;
 
178
</programlisting>
 
179
</informalexample>
 
180
</para>
 
181
 
 
182
 
 
183
<!-- ##### ENUM GDateDMY ##### -->
 
184
<para>
 
185
This enumeration isn't used in the API, but may be useful if you need
 
186
to mark a number as a day, month, or year.
 
187
</para>
 
188
 
 
189
@G_DATE_DAY: a day
 
190
@G_DATE_MONTH: a month
 
191
@G_DATE_YEAR: a year
 
192
 
 
193
<!-- ##### TYPEDEF GDateDay ##### -->
 
194
<para>
 
195
Integer representing a day of the month; between 1 and
 
196
31. #G_DATE_BAD_DAY represents an invalid day of the month.
 
197
</para>
 
198
 
 
199
 
 
200
<!-- ##### ENUM GDateMonth ##### -->
 
201
<para>
 
202
Enumeration representing a month; values are #G_DATE_JANUARY,
 
203
#G_DATE_FEBRUARY, etc. #G_DATE_BAD_MONTH is the invalid value.
 
204
</para>
 
205
 
 
206
@G_DATE_BAD_MONTH: invalid value.
 
207
@G_DATE_JANUARY: January.
 
208
@G_DATE_FEBRUARY: February.
 
209
@G_DATE_MARCH: March.
 
210
@G_DATE_APRIL: April.
 
211
@G_DATE_MAY: May.
 
212
@G_DATE_JUNE: June.
 
213
@G_DATE_JULY: July.
 
214
@G_DATE_AUGUST: August.
 
215
@G_DATE_SEPTEMBER: September.
 
216
@G_DATE_OCTOBER: October.
 
217
@G_DATE_NOVEMBER: November.
 
218
@G_DATE_DECEMBER: December.
 
219
 
 
220
<!-- ##### TYPEDEF GDateYear ##### -->
 
221
<para>
 
222
Integer representing a year; #G_DATE_BAD_YEAR is the invalid
 
223
value. The year must be 1 or higher; negative (BC) years are not
 
224
allowed. The year is represented with four digits.
 
225
</para>
 
226
 
 
227
 
 
228
<!-- ##### ENUM GDateWeekday ##### -->
 
229
<para>
 
230
Enumeration representing a day of the week; #G_DATE_MONDAY,
 
231
#G_DATE_TUESDAY, etc. #G_DATE_BAD_WEEKDAY is an invalid weekday.
 
232
</para>
 
233
 
 
234
@G_DATE_BAD_WEEKDAY: invalid value.
 
235
@G_DATE_MONDAY: Monday.
 
236
@G_DATE_TUESDAY: Tuesday.
 
237
@G_DATE_WEDNESDAY: Wednesday.
 
238
@G_DATE_THURSDAY: Thursday.
 
239
@G_DATE_FRIDAY: Friday.
 
240
@G_DATE_SATURDAY: Saturday.
 
241
@G_DATE_SUNDAY: Sunday.
 
242
 
 
243
<!-- ##### MACRO G_DATE_BAD_DAY ##### -->
 
244
<para>
 
245
Represents an invalid #GDateDay.
 
246
</para>
 
247
 
 
248
 
 
249
 
 
250
<!-- ##### MACRO G_DATE_BAD_JULIAN ##### -->
 
251
<para>
 
252
Represents an invalid Julian day number.
 
253
</para>
 
254
 
 
255
 
 
256
 
 
257
<!-- ##### MACRO G_DATE_BAD_YEAR ##### -->
 
258
<para>
 
259
Represents an invalid year.
 
260
</para>
 
261
 
 
262
 
 
263
 
 
264
<!-- ##### FUNCTION g_date_new ##### -->
 
265
<para>
 
266
Allocates a #GDate and initializes it to a sane state. The new date will
 
267
be cleared (as if you'd called g_date_clear()) but invalid (it won't
 
268
represent an existing day). Free the return value with g_date_free().
 
269
</para>
 
270
 
 
271
@Returns: a newly-allocated #GDate.
 
272
 
 
273
 
 
274
<!-- ##### FUNCTION g_date_new_dmy ##### -->
 
275
<para>
 
276
Like g_date_new(), but also sets the value of the date. Assuming the
 
277
day-month-year triplet you pass in represents an existing day, the
 
278
returned date will be valid.
 
279
</para>
 
280
 
 
281
@day: day of the month.
 
282
@month: month of the year.
 
283
@year: year
 
284
@Returns: a newly-allocated #GDate initialized with @day, @month, and @year.
 
285
 
 
286
 
 
287
<!-- ##### FUNCTION g_date_new_julian ##### -->
 
288
<para>
 
289
Like g_date_new(), but also sets the value of the date. Assuming the
 
290
Julian day number you pass in is valid (greater than 0, less than an
 
291
unreasonably large number), the returned date will be valid.
 
292
</para>
 
293
 
 
294
@julian_day: days since January 1, Year 1.
 
295
@Returns: a newly-allocated #GDate initialized with @julian_day.
 
296
 
 
297
 
 
298
<!-- ##### FUNCTION g_date_clear ##### -->
 
299
<para>
 
300
Initializes one or more #GDate structs to a sane but invalid
 
301
state. The cleared dates will not represent an existing date, but will
 
302
not contain garbage. Useful to init a date declared on the stack.
 
303
Validity can be tested with g_date_valid().
 
304
</para>
 
305
 
 
306
@date: pointer to one or more dates to clear.
 
307
@n_dates: number of dates to clear.
 
308
 
 
309
 
 
310
<!-- ##### FUNCTION g_date_free ##### -->
 
311
<para>
 
312
Frees a #GDate returned from g_date_new().
 
313
</para>
 
314
 
 
315
@date: a #GDate.
 
316
 
 
317
 
 
318
<!-- ##### FUNCTION g_date_set_day ##### -->
 
319
<para>
 
320
Sets the day of the month for a #GDate. If the resulting day-month-year
 
321
triplet is invalid, the date will be invalid.
 
322
</para>
 
323
 
 
324
@date: a #GDate.
 
325
@day: day to set.
 
326
 
 
327
 
 
328
<!-- ##### FUNCTION g_date_set_month ##### -->
 
329
<para>
 
330
Sets the month of the year for a #GDate.  If the resulting
 
331
day-month-year triplet is invalid, the date will be invalid.
 
332
</para>
 
333
 
 
334
@date: a #GDate.
 
335
@month: month to set.
 
336
 
 
337
 
 
338
<!-- ##### FUNCTION g_date_set_year ##### -->
 
339
<para>
 
340
Sets the year for a #GDate. If the resulting day-month-year triplet is
 
341
invalid, the date will be invalid.
 
342
</para>
 
343
 
 
344
@date: a #GDate.
 
345
@year: year to set.
 
346
 
 
347
 
 
348
<!-- ##### FUNCTION g_date_set_dmy ##### -->
 
349
<para>
 
350
Sets the value of a #GDate from a day, month, and year. The day-month-year 
 
351
triplet must be valid; if you aren't sure it is, call g_date_valid_dmy() to
 
352
check before you set it.
 
353
</para>
 
354
 
 
355
@date: a #GDate.
 
356
@day: day.
 
357
@month: month.
 
358
@y: year.
 
359
 
 
360
 
 
361
<!-- ##### FUNCTION g_date_set_julian ##### -->
 
362
<para>
 
363
Sets the value of a #GDate from a Julian day number.
 
364
</para>
 
365
 
 
366
@date: a #GDate.
 
367
@julian_date: Julian day number (days since January 1, Year 1).
 
368
 
 
369
 
 
370
<!-- ##### FUNCTION g_date_set_time ##### -->
 
371
<para>
 
372
 
 
373
</para>
 
374
 
 
375
@date: 
 
376
@time_: 
 
377
 
 
378
 
 
379
<!-- ##### FUNCTION g_date_set_time_t ##### -->
 
380
<para>
 
381
 
 
382
</para>
 
383
 
 
384
@date: 
 
385
@timet: 
 
386
 
 
387
 
 
388
<!-- ##### FUNCTION g_date_set_time_val ##### -->
 
389
<para>
 
390
 
 
391
</para>
 
392
 
 
393
@date: 
 
394
@timeval: 
 
395
 
 
396
 
 
397
<!-- ##### FUNCTION g_date_set_parse ##### -->
 
398
<para>
 
399
Parses a user-inputted string @str, and try to figure out what date it
 
400
represents, taking the current locale into account. If the string is
 
401
successfully parsed, the date will be valid after the call. Otherwise,
 
402
it will be invalid. You should check using g_date_valid() to see
 
403
whether the parsing succeeded.
 
404
</para>
 
405
 
 
406
<para>
 
407
This function is not appropriate for file formats and the like; it
 
408
isn't very precise, and its exact behavior varies with the
 
409
locale. It's intended to be a heuristic routine that guesses what the
 
410
user means by a given string (and it does work pretty well in that
 
411
capacity).
 
412
</para>
 
413
 
 
414
@date: a #GDate to fill in.
 
415
@str: string to parse.
 
416
 
 
417
 
 
418
<!-- ##### FUNCTION g_date_add_days ##### -->
 
419
<para>
 
420
Increments a date some number of days. To move forward by weeks, add
 
421
weeks*7 days. The date must be valid.
 
422
</para>
 
423
 
 
424
@date: a #GDate to increment.
 
425
@n_days: number of days to move the date forward.
 
426
 
 
427
 
 
428
<!-- ##### FUNCTION g_date_subtract_days ##### -->
 
429
<para>
 
430
Moves a date some number of days into the past. To move by weeks, just
 
431
move by weeks*7 days. The date must be valid.
 
432
</para>
 
433
 
 
434
@date: a #GDate to decrement.
 
435
@n_days: number of days to move.
 
436
 
 
437
 
 
438
<!-- ##### FUNCTION g_date_add_months ##### -->
 
439
<para>
 
440
Increments a date by some number of months. If the day of the month is
 
441
greater than 28, this routine may change the day of the month (because
 
442
the destination month may not have the current day in it). The date
 
443
must be valid.
 
444
</para>
 
445
 
 
446
@date: a #GDate to increment.
 
447
@n_months: number of months to move forward.
 
448
 
 
449
 
 
450
<!-- ##### FUNCTION g_date_subtract_months ##### -->
 
451
<para>
 
452
Moves a date some number of months into the past. If the current day of
 
453
the month doesn't exist in the destination month, the day of the month
 
454
may change. The date must be valid.
 
455
</para>
 
456
 
 
457
@date: a #GDate to decrement.
 
458
@n_months: number of months to move.
 
459
 
 
460
 
 
461
<!-- ##### FUNCTION g_date_add_years ##### -->
 
462
<para>
 
463
Increments a date by some number of years. If the date is February 29,
 
464
and the destination year is not a leap year, the date will be changed
 
465
to February 28. The date must be valid.
 
466
</para>
 
467
 
 
468
@date: a #GDate to increment.
 
469
@n_years: number of years to move forward.
 
470
 
 
471
 
 
472
<!-- ##### FUNCTION g_date_subtract_years ##### -->
 
473
<para>
 
474
Moves a date some number of years into the past. If the current day
 
475
doesn't exist in the destination year (i.e. it's February 29 and you
 
476
move to a non-leap-year) then the day is changed to February 29. The date
 
477
must be valid.
 
478
</para>
 
479
 
 
480
@date: a #GDate to decrement.
 
481
@n_years: number of years to move.
 
482
 
 
483
 
 
484
<!-- ##### FUNCTION g_date_days_between ##### -->
 
485
<para>
 
486
Computes the number of days between two dates.
 
487
If @date2 is prior to @date1, the returned value is negative.
 
488
Both dates must be valid.
 
489
</para>
 
490
 
 
491
@date1: the first date.
 
492
@date2: the second date.
 
493
@Returns: the number of days between @date1 and @date2.
 
494
 
 
495
 
 
496
<!-- ##### FUNCTION g_date_compare ##### -->
 
497
<para>
 
498
<function>qsort()</function>-style comparsion function for dates. Both
 
499
dates must be valid.
 
500
</para>
 
501
 
 
502
@lhs: first date to compare.
 
503
@rhs: second date to compare.
 
504
@Returns: 0 for equal, less than zero if @lhs is less than @rhs,
 
505
greater than zero if @lhs is greater than @rhs.
 
506
 
 
507
 
 
508
<!-- ##### FUNCTION g_date_clamp ##### -->
 
509
<para>
 
510
If @date is prior to @min_date, sets @date equal to @min_date.
 
511
If @date falls after @max_date, sets @date equal to @max_date.
 
512
Either @min_date and @max_date may be %NULL.  All non-%NULL dates
 
513
must be valid.
 
514
</para>
 
515
 
 
516
@date: a #GDate to clamp.
 
517
@min_date: minimum accepted value for @date.
 
518
@max_date: maximum accepted value for @date.
 
519
 
 
520
 
 
521
<!-- ##### FUNCTION g_date_order ##### -->
 
522
<para>
 
523
Checks if @date1 is less than or equal to @date2,
 
524
and swap the values if this is not the case.
 
525
</para>
 
526
 
 
527
@date1: the first date.
 
528
@date2: the second date.
 
529
 
 
530
 
 
531
<!-- ##### FUNCTION g_date_get_day ##### -->
 
532
<para>
 
533
Returns the day of the month. The date must be valid.
 
534
</para>
 
535
 
 
536
@date: a #GDate to extract the day of the month from.
 
537
@Returns: day of the month.
 
538
 
 
539
 
 
540
<!-- ##### FUNCTION g_date_get_month ##### -->
 
541
<para>
 
542
Returns the month of the year. The date must be valid.
 
543
</para>
 
544
 
 
545
@date: a #GDate to get the month from.
 
546
@Returns: month of the year as a #GDateMonth.
 
547
 
 
548
 
 
549
<!-- ##### FUNCTION g_date_get_year ##### -->
 
550
<para>
 
551
Returns the year of a #GDate. The date must be valid.
 
552
</para>
 
553
 
 
554
@date: a #GDate.
 
555
@Returns: year in which the date falls.
 
556
 
 
557
 
 
558
<!-- ##### FUNCTION g_date_get_julian ##### -->
 
559
<para>
 
560
Returns the Julian day or "serial number" of the #GDate. The
 
561
Julian day is simply the number of days since January 1, Year 1; i.e.,
 
562
January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
 
563
etc. The date must be valid.
 
564
</para>
 
565
 
 
566
@date: a #GDate to extract the Julian day from.
 
567
@Returns: Julian day.
 
568
 
 
569
 
 
570
<!-- ##### FUNCTION g_date_get_weekday ##### -->
 
571
<para>
 
572
Returns the day of the week for a #GDate. The date must be valid.
 
573
</para>
 
574
 
 
575
@date: a #GDate.
 
576
@Returns: day of the week as a #GDateWeekday.
 
577
 
 
578
 
 
579
<!-- ##### FUNCTION g_date_get_day_of_year ##### -->
 
580
<para>
 
581
Returns the day of the year, where Jan 1 is the first day of the
 
582
year. The date must be valid.
 
583
</para>
 
584
 
 
585
@date: a #GDate to extract day of year from.
 
586
@Returns: day of the year.
 
587
 
 
588
 
 
589
<!-- ##### FUNCTION g_date_get_days_in_month ##### -->
 
590
<para>
 
591
Returns the number of days in a month, taking leap years into account.
 
592
</para>
 
593
 
 
594
@month: month.
 
595
@year: year.
 
596
@Returns: number of days in @month during the @year.
 
597
 
 
598
 
 
599
<!-- ##### FUNCTION g_date_is_first_of_month ##### -->
 
600
<para>
 
601
Returns %TRUE if the date is on the first of a month. The date must be valid.
 
602
</para>
 
603
 
 
604
@date: a #GDate to check.
 
605
@Returns: %TRUE if the date is the first of the month.
 
606
 
 
607
 
 
608
<!-- ##### FUNCTION g_date_is_last_of_month ##### -->
 
609
<para>
 
610
Returns %TRUE if the date is the last day of the month. The date must be valid.
 
611
</para>
 
612
 
 
613
@date: a #GDate to check.
 
614
@Returns: %TRUE if the date is the last day of the month.
 
615
 
 
616
 
 
617
<!-- ##### FUNCTION g_date_is_leap_year ##### -->
 
618
<para>
 
619
Returns %TRUE if the year is a leap year.
 
620
</para>
 
621
 
 
622
@year: year to check.
 
623
@Returns: %TRUE if the year is a leap year.
 
624
 
 
625
 
 
626
<!-- ##### FUNCTION g_date_get_monday_week_of_year ##### -->
 
627
<para>
 
628
Returns the week of the year, where weeks are understood to start on
 
629
Monday. If the date is before the first Monday of the year, return
 
630
0. The date must be valid.
 
631
</para>
 
632
 
 
633
@date: a #GDate.
 
634
@Returns: week of the year.
 
635
 
 
636
 
 
637
<!-- ##### FUNCTION g_date_get_monday_weeks_in_year ##### -->
 
638
<para>
 
639
Returns the number of weeks in the year, where weeks are taken to start
 
640
on Monday. Will be 52 or 53. The date must be valid. (Years always have 52
 
641
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
 
642
year. This function is basically telling you how many Mondays are in
 
643
the year, i.e. there are 53 Mondays if one of the extra days happens
 
644
to be a Monday.)
 
645
</para>
 
646
 
 
647
@year: a year.
 
648
@Returns: number of Mondays in the year.
 
649
 
 
650
 
 
651
<!-- ##### FUNCTION g_date_get_sunday_week_of_year ##### -->
 
652
<para>
 
653
Returns the week of the year during which this date falls, if weeks 
 
654
are understood to being on Sunday. The date must be valid. Can return 0 if 
 
655
the day is before the first Sunday of the year.
 
656
</para>
 
657
 
 
658
@date: a #GDate.
 
659
@Returns: week number.
 
660
 
 
661
 
 
662
<!-- ##### FUNCTION g_date_get_sunday_weeks_in_year ##### -->
 
663
<para>
 
664
Returns the number of weeks in the year, where weeks are taken to start
 
665
on Sunday. Will be 52 or 53. The date must be valid. (Years always have 52
 
666
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
 
667
year. This function is basically telling you how many Sundays are in
 
668
the year, i.e. there are 53 Sundays if one of the extra days happens
 
669
to be a Sunday.)
 
670
</para>
 
671
 
 
672
@year: year to count weeks in.
 
673
@Returns: number of weeks.
 
674
 
 
675
 
 
676
<!-- ##### FUNCTION g_date_get_iso8601_week_of_year ##### -->
 
677
<para>
 
678
 
 
679
</para>
 
680
 
 
681
@date: 
 
682
@Returns: 
 
683
 
 
684
 
 
685
<!-- ##### FUNCTION g_date_strftime ##### -->
 
686
<para>
 
687
Generates a printed representation of the date, in a locale-specific
 
688
way. Works just like the platform's C library
 
689
<function>strftime()</function> function, but only accepts
 
690
date-related formats; time-related formats give undefined
 
691
results. Date must be valid. Unlike <function>strftime()</function>
 
692
(which uses the locale encoding), works on a UTF-8 format string and
 
693
stores a UTF-8 result.
 
694
</para>
 
695
 
 
696
<para>
 
697
This function does not provide any conversion specifiers in addition
 
698
to those implemented by the platform's C library. For example, don't
 
699
expect that using <function>g_date_strftime()</function> would make
 
700
the %F provided by the C99 <function>strftime()</function> work on
 
701
Windows where the C library only complies to C89.
 
702
</para>
 
703
 
 
704
@s: destination buffer.
 
705
@slen: buffer size.
 
706
@format: format string.
 
707
@date: valid #GDate.
 
708
@Returns: number of characters written to the buffer, or 0 the buffer was too small.
 
709
 
 
710
 
 
711
<!-- ##### FUNCTION g_date_to_struct_tm ##### -->
 
712
<para>
 
713
Fills in the date-related bits of a <structname>struct tm</structname>
 
714
using the @date value. Initializes the non-date parts with something
 
715
sane but meaningless.
 
716
</para>
 
717
 
 
718
@date: a #GDate to set the <structname>struct tm</structname> from.
 
719
@tm: <structname>struct tm</structname> to fill.
 
720
 
 
721
 
 
722
<!-- ##### FUNCTION g_date_valid ##### -->
 
723
<para>
 
724
Returns %TRUE if the #GDate represents an existing day. The date must not
 
725
contain garbage; it should have been initialized with g_date_clear()
 
726
if it wasn't allocated by one of the g_date_new() variants.
 
727
</para>
 
728
 
 
729
@date: a #GDate to check.
 
730
@Returns: Whether the date is valid.
 
731
 
 
732
 
 
733
<!-- ##### FUNCTION g_date_valid_day ##### -->
 
734
<para>
 
735
Returns %TRUE if the day of the month is valid (a day is valid if it's
 
736
between 1 and 31 inclusive).
 
737
</para>
 
738
 
 
739
@day: day to check.
 
740
@Returns: %TRUE if the day is valid.
 
741
 
 
742
 
 
743
<!-- ##### FUNCTION g_date_valid_month ##### -->
 
744
<para>
 
745
Returns %TRUE if the month value is valid. The 12 #GDateMonth
 
746
enumeration values are the only valid months.
 
747
</para>
 
748
 
 
749
@month: month.
 
750
@Returns: %TRUE if the month is valid.
 
751
 
 
752
 
 
753
<!-- ##### FUNCTION g_date_valid_year ##### -->
 
754
<para>
 
755
Returns %TRUE if the year is valid. Any year greater than 0 is valid,
 
756
though there is a 16-bit limit to what #GDate will understand.
 
757
</para>
 
758
 
 
759
@year: year.
 
760
@Returns: %TRUE if the year is valid.
 
761
 
 
762
 
 
763
<!-- ##### FUNCTION g_date_valid_dmy ##### -->
 
764
<para>
 
765
Returns %TRUE if the day-month-year triplet forms a valid, existing day
 
766
in the range of days #GDate understands (Year 1 or later, no more than
 
767
a few thousand years in the future).
 
768
</para>
 
769
 
 
770
@day: day.
 
771
@month: month.
 
772
@year: year.
 
773
@Returns: %TRUE if the date is a valid one.
 
774
 
 
775
 
 
776
<!-- ##### FUNCTION g_date_valid_julian ##### -->
 
777
<para>
 
778
Returns %TRUE if the Julian day is valid. Anything greater than zero is basically a
 
779
valid Julian, though there is a 32-bit limit.
 
780
</para>
 
781
 
 
782
@julian_date: Julian day to check.
 
783
@Returns: %TRUE if the Julian day is valid.
 
784
 
 
785
 
 
786
<!-- ##### FUNCTION g_date_valid_weekday ##### -->
 
787
<para>
 
788
Returns %TRUE if the weekday is valid. The 7 #GDateWeekday enumeration
 
789
values are the only valid weekdays.
 
790
</para>
 
791
 
 
792
@weekday: weekday.
 
793
@Returns: %TRUE if the weekday is valid.
 
794
 
 
795