2
// Generated by gtkmmproc -- DO NOT MODIFY!
9
/* Copyright (C) 2002 The gtkmm Development Team
11
* This library is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Library General Public
13
* License as published by the Free Software Foundation; either
14
* version 2 of the License, or (at your option) any later version.
16
* This library is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Library General Public License for more details.
21
* You should have received a copy of the GNU Library General Public
22
* License along with this library; if not, write to the Free
23
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
#include <glibmm/ustring.h>
29
#include <glib/gdate.h>
30
#include <glib/gtypes.h>
32
#ifndef DOXYGEN_SHOULD_SKIP_THIS
33
extern "C" { struct tm; }
40
/** Julian calendar date.
48
/** @addtogroup glibmmEnums Enums and Flags */
51
* @ingroup glibmmEnums
72
* @ingroup glibmmEnums
88
* @ingroup glibmmEnums
98
static const Day BAD_DAY = 0;
99
static const Year BAD_YEAR = 0;
100
static const guint32 BAD_JULIAN = 0;
103
Date(Day day, Month month, Year year);
104
explicit Date(guint32 julian_day);
106
#ifndef DOXYGEN_SHOULD_SKIP_THIS
107
explicit Date(const GDate& castitem);
111
/** Clear the date. The cleared dates will not represent an existing date, but will not contain garbage.
112
* @param month Month to set.
115
/** Parses a user-inputted string str, and try to figure out what date it represents, taking the current locale into account. If the string is successfully parsed, the date will be valid after the call. Otherwise, it will be invalid.
116
* This function is not appropriate for file formats and the like; it isn't very precise, and its exact behavior varies with the locale. It's intended to be a heuristic routine that guesses what the user means by a given string (and it does work pretty well in that capacity).
117
* @param str String to parse.
119
void set_parse (const Glib::ustring& str);
121
//TODO: Add set_time_current() - see the docs comment below.?
122
/** Sets the value of a date from a GTime (time_t) value.
123
* To set the value of a date to the current day, you could write:
125
*set_time(time(NULL));
127
* @param time GTime value to set.
129
void set_time(GTime time);
131
/** Sets the month of the year. If the resulting day-month-year triplet is invalid, the date will be invalid.
132
* @param month Month to set.
134
void set_month(Month month);
136
/** Sets the day of the month. If the resulting day-month-year triplet is invalid, the date will be invalid.
137
* @param day Day to set.
139
void set_day(Day day);
141
/** Sets the year. If the resulting day-month-year triplet is invalid, the date will be invalid.
142
* @param year Year to set.
144
void set_year(Year year);
146
/** Sets the value of a day, month, and year.. If the resulting day-month-year triplet is invalid, the date will be invalid.
147
* @param day Day to set.
148
* @param month Month to set.
149
* @param year Year to set.
151
void set_dmy(Day day, Month month, Year year);
153
/** Sets the value of a GDate from a Julian day number.
154
* @param julian_day Julian day to set.
156
void set_julian(guint32 julian_day);
158
//TODO: Why return Date& (which is always *this) from these methods?
159
//Isn't it enough to also change the current instance?
160
//Maybe we need a copy constructor too.
163
/** Add a number of days to a Date.
164
* @param n_days Days to add.
165
* @return Resulting Date
167
Date& add_days(int n_days);
169
/** Subtract n_days to a Date.
170
* @param n_days Days to subtract.
171
* @return Resulting Date
173
Date& subtract_days(int n_days);
175
/** Add n_months to a Date.
176
* @param n_months Months to add.
177
* @return Resulting Date
179
Date& add_months(int n_months);
181
/** Subtract n_months to a Date.
182
* @param n_months Months to subtract.
183
* @return Resulting Date
185
Date& subtract_months(int n_months);
187
/** Add n_days to a Date.
188
* @param n_years Years to add.
189
* @return Resulting Date
191
Date& add_years(int n_years);
193
/** Subtract n_years to a Date.
194
* @param n_years Years to subtract.
195
* @return Resulting Date
197
Date& subtract_years(int n_years);
199
/** Calculate days between two dates.
201
* @return Numbers of days.
203
int days_between(const Date& rhs) const;
205
/** Compare two dates.
206
* @param rhs Date to compare.
207
* @return Result of comparition.
209
int compare(const Date& rhs) const;
211
/** If date is prior to min_date, sets date equal to min_date.
212
* If date falls after max_date, sets date equal to max_date. All dates must be valid.
213
* See also clamp_min() and clamp_max().
214
* @param min_date Date minimum value.
215
* @param max_date Date maximum value.
216
* @return Date in interval.
218
Date& clamp(const Date& min_date, const Date& max_date);
220
/** If date is prior to min_date, sets date equal to min_date.
221
* See also clamp(), and clamp_max().
222
* @param min_date Date minimum value.
223
* @return Date in interval.
225
Date& clamp_min(const Date& min_date);
227
/** If date falls after max_date, sets date equal to max_date.
228
* See also clamp(), and clamp_min().
229
* @param max_date Date maximum value.
230
* @return Date in interval.
232
Date& clamp_max(const Date& max_date);
234
/** Checks if date is less than or equal to other date, and swap the values if this is not the case.
235
* @param other Date ro compare.
238
void order(Date& other);
240
/** Returns the day of the week for a Date. The date must be valid.
241
* @return Day of the week as a Date::Weekday.
243
Weekday get_weekday() const;
245
/** Returns the month of the year. The date must be valid.
246
* @return Month of the year as a Date::Month.
248
Month get_month() const;
250
/** Returns the year of a Date. The date must be valid.
251
* @return Year in which the date falls.
253
Year get_year() const;
255
/** Returns the day of the month. The date must be valid.
256
* @return Day of the month..
260
/** Returns the Julian day or "serial number" of the Date.
261
* The Julian day is simply the number of days since January 1, Year 1;
262
* i.e., January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2, etc.
263
* The date must be valid.
264
* @return Julian day.
266
guint32 get_julian() const;
268
/** Returns the day of the year, where Jan 1 is the first day of the year.
269
* The date must be valid.
270
* @return Julian day.
272
unsigned int get_day_of_year() const;
274
/** Returns the week of the year, where weeks are understood to start on Monday.
275
* If the date is before the first Monday of the year, return 0.
276
* The date must be valid.
277
* @return Week of the year.
279
unsigned int get_monday_week_of_year() const;
281
/** Returns the week of the year during which this date falls, if weeks are understood to being on Sunday.
282
* Can return 0 if the day is before the first Sunday of the year.
283
* The date must be valid.
284
* @return Week of the year.
286
unsigned int get_sunday_week_of_year() const;
288
/** Returns true if the date is on the first of a month.
289
* The date must be valid.
290
* @return true if the date is the first of the month.
292
bool is_first_of_month() const;
294
/** Returns true if the date is the last day of the month.
295
* The date must be valid.
296
* @return true if the date is the last day of the month.
298
bool is_last_of_month() const;
300
/** Returns the number of days in a month, taking leap years into account.
301
* @param month Month.
303
* @return Number of days in month during the year.
305
static guint8 get_days_in_month(Month month, Year year);
307
/** Returns the number of weeks in the year, where weeks are taken to start on Monday. Will be 52 or 53.
308
* (Years always have 52 7-day periods, plus 1 or 2 extra days depending on whether it's a leap year. This function is basically telling you how many Mondays are in the year, i.e. there are 53 Mondays if one of the extra days happens to be a Monday.)
309
* @param year Year to count weeks in.
310
* @return Number of weeks.
312
static guint8 get_monday_weeks_in_year(Year year);
314
/** Returns the number of weeks in the year, where weeks are taken to start on Sunday. Will be 52 or 53.
315
* (Years always have 52 7-day periods, plus 1 or 2 extra days depending on whether it's a leap year. This function is basically telling you how many Sundays are in the year, i.e. there are 53 Sundays if one of the extra days happens to be a Sunday.)
316
* @param year Year to count weeks in.
317
* @return Number of weeks.
319
static guint8 get_sunday_weeks_in_year(Year year);
321
/** Returns true if the year is a leap year.
322
* @param year Year to check.
323
* @return true if the year is a leap year.
325
static bool is_leap_year(Year year);
327
/** Convert date to string.
328
* @param format A format string as used by @c strftime(), in UTF-8
329
* encoding. Only date formats are allowed, the result of time formats
331
* @return The formatted date string.
332
* @throw Glib::ConvertError
334
Glib::ustring format_string(const Glib::ustring& format) const;
336
/** Fills in the date-related bits of a struct tm using the date value. Initializes the non-date parts with something sane but meaningless.
337
* @param dest Struct tm to fill.
339
void to_struct_tm(struct tm& dest) const;
341
/** Returns true if the Date represents an existing day.
342
* @return true if the date is valid.
346
/** Returns true if the day of the month is valid (a day is valid if it's between 1 and 31 inclusive).
347
* @param day Day to check.
348
* @return true if the day is valid.
350
static bool valid_day(Day day);
352
/** Returns true if the month value is valid. The 12 Date::Month enumeration values are the only valid months.
353
* @param month Month to check.
354
* @return true if the month is valid.
356
static bool valid_month(Month month);
359
/** Returns true if the year is valid.
360
* Any year greater than 0 is valid, though there is a 16-bit limit to what Date will understand.
361
* @param year Year to check.
362
* @return true if the year is valid.
364
static bool valid_year(Year year);
366
/** Returns true if the weekday is valid.
367
* The 7 Date::Weekday enumeration values are the only valid.
368
* @param weekday Weekday to check.
369
* @return true if the weekday is valid.
371
static bool valid_weekday(Weekday weekday);
373
/** Returns true if the Julian day is valid.
374
* Anything greater than zero is basically a valid Julian, though there is a 32-bit limit.
375
* @param julian_day Julian day to check.
376
* @return true if the Julian day is valid.
378
static bool valid_julian(guint32 julian_day);
381
/** Returns true if the day-month-year triplet forms a valid, existing day in the range of days Date understands (Year 1 or later, no more than a few thousand years in the future).
382
* @param day Day to check.
383
* @param month Month to check.
384
* @param year Year to check.
385
* @return true if the date is a valid one.
387
static bool valid_dmy(Day day, Month month, Year year);
389
#ifndef DOXYGEN_SHOULD_SKIP_THIS
390
GDate* gobj() { return &gobject_; }
391
const GDate* gobj() const { return &gobject_; }
399
/** @relates Glib::Date */
400
inline bool operator==(const Date& lhs, const Date& rhs)
401
{ return (lhs.compare(rhs) == 0); }
403
/** @relates Glib::Date */
404
inline bool operator!=(const Date& lhs, const Date& rhs)
405
{ return (lhs.compare(rhs) != 0); }
407
/** @relates Glib::Date */
408
inline bool operator<(const Date& lhs, const Date& rhs)
409
{ return (lhs.compare(rhs) < 0); }
411
/** @relates Glib::Date */
412
inline bool operator>(const Date& lhs, const Date& rhs)
413
{ return (lhs.compare(rhs) > 0); }
415
/** @relates Glib::Date */
416
inline bool operator<=(const Date& lhs, const Date& rhs)
417
{ return (lhs.compare(rhs) <= 0); }
419
/** @relates Glib::Date */
420
inline bool operator>=(const Date& lhs, const Date& rhs)
421
{ return (lhs.compare(rhs) >= 0); }
426
#endif /* _GLIBMM_DATE_H */