1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = 27 * outPack = glib 28 * outFile = Date 29 * strct = GDate 30 * realStrct= 31 * ctorStrct= 32 * clss = Date 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_date_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - gtkc.Loader 48 * - gtkc.paths 49 * structWrap: 50 * - GDate* -> Date 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module glib.Date; 57 58 public import gtkc.glibtypes; 59 60 private import gtkc.glib; 61 private import glib.ConstructionException; 62 63 64 private import glib.Str; 65 private import gtkc.Loader; 66 private import gtkc.paths; 67 68 69 70 71 /** 72 * The GDate data structure represents a day between January 1, Year 1, 73 * and sometime a few thousand years in the future (right now it will go 74 * to the year 65535 or so, but g_date_set_parse() only parses up to the 75 * year 8000 or so - just count on "a few thousand"). GDate is meant to 76 * represent everyday dates, not astronomical dates or historical dates 77 * or ISO timestamps or the like. It extrapolates the current Gregorian 78 * calendar forward and backward in time; there is no attempt to change 79 * the calendar to match time periods or locations. GDate does not store 80 * time information; it represents a day. 81 * 82 * The GDate implementation has several nice features; it is only a 83 * 64-bit struct, so storing large numbers of dates is very efficient. It 84 * can keep both a Julian and day-month-year representation of the date, 85 * since some calculations are much easier with one representation or the 86 * other. A Julian representation is simply a count of days since some 87 * fixed day in the past; for GDate the fixed day is January 1, 1 AD. 88 * ("Julian" dates in the GDate API aren't really Julian dates in the 89 * technical sense; technically, Julian dates count from the start of the 90 * Julian period, Jan 1, 4713 BC). 91 * 92 * GDate is simple to use. First you need a "blank" date; you can get a 93 * dynamically allocated date from g_date_new(), or you can declare an 94 * automatic variable or array and initialize it to a sane state by 95 * calling g_date_clear(). A cleared date is sane; it's safe to call 96 * g_date_set_dmy() and the other mutator functions to initialize the 97 * value of a cleared date. However, a cleared date is initially 98 * invalid, meaning that it doesn't represent a day 99 * that exists. It is undefined to call any of the date calculation 100 * routines on an invalid date. If you obtain a date from a user or other 101 * unpredictable source, you should check its validity with the 102 * g_date_valid() predicate. g_date_valid() is also used to check for 103 * errors with g_date_set_parse() and other functions that can 104 * fail. Dates can be invalidated by calling g_date_clear() again. 105 * 106 * It is very important to use the API to access the GDate 107 * struct. Often only the day-month-year or only the Julian 108 * representation is valid. Sometimes neither is valid. Use the API. 109 * 110 * GLib also features GDateTime which represents a precise time. 111 */ 112 public class Date 113 { 114 115 /** the main Gtk struct */ 116 protected GDate* gDate; 117 118 119 public GDate* getDateStruct() 120 { 121 return gDate; 122 } 123 124 125 /** the main Gtk struct as a void* */ 126 protected void* getStruct() 127 { 128 return cast(void*)gDate; 129 } 130 131 /** 132 * Sets our main struct and passes it to the parent class 133 */ 134 public this (GDate* gDate) 135 { 136 this.gDate = gDate; 137 } 138 139 ~this () 140 { 141 if ( Linker.isLoaded(LIBRARY.GLIB) && gDate !is null ) 142 { 143 g_date_free(gDate); 144 } 145 } 146 147 /** 148 */ 149 150 /** 151 * Allocates a GDate and initializes 152 * it to a sane state. The new date will 153 * be cleared (as if you'd called g_date_clear()) but invalid (it won't 154 * represent an existing day). Free the return value with g_date_free(). 155 * Throws: ConstructionException GTK+ fails to create the object. 156 */ 157 public this () 158 { 159 // GDate * g_date_new (void); 160 auto p = g_date_new(); 161 if(p is null) 162 { 163 throw new ConstructionException("null returned by g_date_new()"); 164 } 165 this(cast(GDate*) p); 166 } 167 168 /** 169 * Like g_date_new(), but also sets the value of the date. Assuming the 170 * day-month-year triplet you pass in represents an existing day, the 171 * returned date will be valid. 172 * Params: 173 * day = day of the month 174 * month = month of the year 175 * year = year 176 * Throws: ConstructionException GTK+ fails to create the object. 177 */ 178 public this (GDateDay day, GDateMonth month, GDateYear year) 179 { 180 // GDate * g_date_new_dmy (GDateDay day, GDateMonth month, GDateYear year); 181 auto p = g_date_new_dmy(day, month, year); 182 if(p is null) 183 { 184 throw new ConstructionException("null returned by g_date_new_dmy(day, month, year)"); 185 } 186 this(cast(GDate*) p); 187 } 188 189 /** 190 * Like g_date_new(), but also sets the value of the date. Assuming the 191 * Julian day number you pass in is valid (greater than 0, less than an 192 * unreasonably large number), the returned date will be valid. 193 * Params: 194 * julianDay = days since January 1, Year 1 195 * Throws: ConstructionException GTK+ fails to create the object. 196 */ 197 public this (uint julianDay) 198 { 199 // GDate * g_date_new_julian (guint32 julian_day); 200 auto p = g_date_new_julian(julianDay); 201 if(p is null) 202 { 203 throw new ConstructionException("null returned by g_date_new_julian(julianDay)"); 204 } 205 this(cast(GDate*) p); 206 } 207 208 /** 209 * Initializes one or more GDate structs to a sane but invalid 210 * state. The cleared dates will not represent an existing date, but will 211 * not contain garbage. Useful to init a date declared on the stack. 212 * Validity can be tested with g_date_valid(). 213 * Params: 214 * nDates = number of dates to clear 215 */ 216 public void clear(uint nDates) 217 { 218 // void g_date_clear (GDate *date, guint n_dates); 219 g_date_clear(gDate, nDates); 220 } 221 222 /** 223 * Frees a GDate returned from g_date_new(). 224 */ 225 public void free() 226 { 227 // void g_date_free (GDate *date); 228 g_date_free(gDate); 229 } 230 231 /** 232 * Sets the day of the month for a GDate. If the resulting 233 * day-month-year triplet is invalid, the date will be invalid. 234 * Params: 235 * day = day to set 236 */ 237 public void setDay(GDateDay day) 238 { 239 // void g_date_set_day (GDate *date, GDateDay day); 240 g_date_set_day(gDate, day); 241 } 242 243 /** 244 * Sets the month of the year for a GDate. If the resulting 245 * day-month-year triplet is invalid, the date will be invalid. 246 * Params: 247 * month = month to set 248 */ 249 public void setMonth(GDateMonth month) 250 { 251 // void g_date_set_month (GDate *date, GDateMonth month); 252 g_date_set_month(gDate, month); 253 } 254 255 /** 256 * Sets the year for a GDate. If the resulting day-month-year 257 * triplet is invalid, the date will be invalid. 258 * Params: 259 * year = year to set 260 */ 261 public void setYear(GDateYear year) 262 { 263 // void g_date_set_year (GDate *date, GDateYear year); 264 g_date_set_year(gDate, year); 265 } 266 267 /** 268 * Sets the value of a GDate from a day, month, and year. 269 * The day-month-year triplet must be valid; if you aren't 270 * sure it is, call g_date_valid_dmy() to check before you 271 * set it. 272 * Params: 273 * day = day 274 * month = month 275 * y = year 276 */ 277 public void setDmy(GDateDay day, GDateMonth month, GDateYear y) 278 { 279 // void g_date_set_dmy (GDate *date, GDateDay day, GDateMonth month, GDateYear y); 280 g_date_set_dmy(gDate, day, month, y); 281 } 282 283 /** 284 * Sets the value of a GDate from a Julian day number. 285 * Params: 286 * julianDate = Julian day number (days since January 1, Year 1) 287 */ 288 public void setJulian(uint julianDate) 289 { 290 // void g_date_set_julian (GDate *date, guint32 julian_date); 291 g_date_set_julian(gDate, julianDate); 292 } 293 294 /** 295 * Warning 296 * g_date_set_time has been deprecated since version 2.10 and should not be used in newly-written code. Use g_date_set_time_t() instead. 297 * Sets the value of a date from a GTime value. 298 * The time to date conversion is done using the user's current timezone. 299 * Params: 300 * time = GTime value to set. 301 */ 302 public void setTime(GTime time) 303 { 304 // void g_date_set_time (GDate *date, GTime time_); 305 g_date_set_time(gDate, time); 306 } 307 308 /** 309 * Sets the value of a date to the date corresponding to a time 310 * specified as a time_t. The time to date conversion is done using 311 * the user's current timezone. 312 * Since 2.10 313 * Params: 314 * timet = time_t value to set 315 */ 316 public void setTimeT(uint timet) 317 { 318 // void g_date_set_time_t (GDate *date, time_t timet); 319 g_date_set_time_t(gDate, timet); 320 } 321 322 /** 323 * Sets the value of a date from a GTimeVal value. Note that the 324 * tv_usec member is ignored, because GDate can't make use of the 325 * additional precision. 326 * The time to date conversion is done using the user's current timezone. 327 * Since 2.10 328 * Params: 329 * timeval = GTimeVal value to set 330 */ 331 public void setTimeVal(ref GTimeVal timeval) 332 { 333 // void g_date_set_time_val (GDate *date, GTimeVal *timeval); 334 g_date_set_time_val(gDate, &timeval); 335 } 336 337 /** 338 * Parses a user-inputted string str, and try to figure out what date it 339 * represents, taking the current locale 340 * into account. If the string is successfully parsed, the date will be 341 * valid after the call. Otherwise, it will be invalid. You should check 342 * using g_date_valid() to see whether the parsing succeeded. 343 * This function is not appropriate for file formats and the like; it 344 * isn't very precise, and its exact behavior varies with the locale. 345 * It's intended to be a heuristic routine that guesses what the user 346 * means by a given string (and it does work pretty well in that 347 * capacity). 348 * Params: 349 * str = string to parse 350 */ 351 public void setParse(string str) 352 { 353 // void g_date_set_parse (GDate *date, const gchar *str); 354 g_date_set_parse(gDate, Str.toStringz(str)); 355 } 356 357 /** 358 * Increments a date some number of days. 359 * To move forward by weeks, add weeks*7 days. 360 * The date must be valid. 361 * Params: 362 * nDays = number of days to move the date forward 363 */ 364 public void addDays(uint nDays) 365 { 366 // void g_date_add_days (GDate *date, guint n_days); 367 g_date_add_days(gDate, nDays); 368 } 369 370 /** 371 * Moves a date some number of days into the past. 372 * To move by weeks, just move by weeks*7 days. 373 * The date must be valid. 374 * Params: 375 * nDays = number of days to move 376 */ 377 public void subtractDays(uint nDays) 378 { 379 // void g_date_subtract_days (GDate *date, guint n_days); 380 g_date_subtract_days(gDate, nDays); 381 } 382 383 /** 384 * Increments a date by some number of months. 385 * If the day of the month is greater than 28, 386 * this routine may change the day of the month 387 * (because the destination month may not have 388 * the current day in it). The date must be valid. 389 * Params: 390 * nMonths = number of months to move forward 391 */ 392 public void addMonths(uint nMonths) 393 { 394 // void g_date_add_months (GDate *date, guint n_months); 395 g_date_add_months(gDate, nMonths); 396 } 397 398 /** 399 * Moves a date some number of months into the past. 400 * If the current day of the month doesn't exist in 401 * the destination month, the day of the month 402 * may change. The date must be valid. 403 * Params: 404 * nMonths = number of months to move 405 */ 406 public void subtractMonths(uint nMonths) 407 { 408 // void g_date_subtract_months (GDate *date, guint n_months); 409 g_date_subtract_months(gDate, nMonths); 410 } 411 412 /** 413 * Increments a date by some number of years. 414 * If the date is February 29, and the destination 415 * year is not a leap year, the date will be changed 416 * to February 28. The date must be valid. 417 * Params: 418 * nYears = number of years to move forward 419 */ 420 public void addYears(uint nYears) 421 { 422 // void g_date_add_years (GDate *date, guint n_years); 423 g_date_add_years(gDate, nYears); 424 } 425 426 /** 427 * Moves a date some number of years into the past. 428 * If the current day doesn't exist in the destination 429 * year (i.e. it's February 29 and you move to a non-leap-year) 430 * then the day is changed to February 29. The date 431 * must be valid. 432 * Params: 433 * nYears = number of years to move 434 */ 435 public void subtractYears(uint nYears) 436 { 437 // void g_date_subtract_years (GDate *date, guint n_years); 438 g_date_subtract_years(gDate, nYears); 439 } 440 441 /** 442 * Computes the number of days between two dates. 443 * If date2 is prior to date1, the returned value is negative. 444 * Both dates must be valid. 445 * Params: 446 * date2 = the second date 447 * Returns: the number of days between date1 and date2 448 */ 449 public int daysBetween(Date date2) 450 { 451 // gint g_date_days_between (const GDate *date1, const GDate *date2); 452 return g_date_days_between(gDate, (date2 is null) ? null : date2.getDateStruct()); 453 } 454 455 /** 456 * qsort()-style comparison function for dates. 457 * Both dates must be valid. 458 * Params: 459 * rhs = second date to compare 460 * Returns: 0 for equal, less than zero if lhs is less than rhs, greater than zero if lhs is greater than rhs 461 */ 462 public int compare(Date rhs) 463 { 464 // gint g_date_compare (const GDate *lhs, const GDate *rhs); 465 return g_date_compare(gDate, (rhs is null) ? null : rhs.getDateStruct()); 466 } 467 468 /** 469 * If date is prior to min_date, sets date equal to min_date. 470 * If date falls after max_date, sets date equal to max_date. 471 * Otherwise, date is unchanged. 472 * Either of min_date and max_date may be NULL. 473 * All non-NULL dates must be valid. 474 * Params: 475 * minDate = minimum accepted value for date 476 * maxDate = maximum accepted value for date 477 */ 478 public void clamp(Date minDate, Date maxDate) 479 { 480 // void g_date_clamp (GDate *date, const GDate *min_date, const GDate *max_date); 481 g_date_clamp(gDate, (minDate is null) ? null : minDate.getDateStruct(), (maxDate is null) ? null : maxDate.getDateStruct()); 482 } 483 484 /** 485 * Checks if date1 is less than or equal to date2, 486 * and swap the values if this is not the case. 487 * Params: 488 * date2 = the second date 489 */ 490 public void order(Date date2) 491 { 492 // void g_date_order (GDate *date1, GDate *date2); 493 g_date_order(gDate, (date2 is null) ? null : date2.getDateStruct()); 494 } 495 496 /** 497 * Returns the day of the month. The date must be valid. 498 * Returns: day of the month 499 */ 500 public GDateDay getDay() 501 { 502 // GDateDay g_date_get_day (const GDate *date); 503 return g_date_get_day(gDate); 504 } 505 506 /** 507 * Returns the month of the year. The date must be valid. 508 * Returns: month of the year as a GDateMonth 509 */ 510 public GDateMonth getMonth() 511 { 512 // GDateMonth g_date_get_month (const GDate *date); 513 return g_date_get_month(gDate); 514 } 515 516 /** 517 * Returns the year of a GDate. The date must be valid. 518 * Returns: year in which the date falls 519 */ 520 public GDateYear getYear() 521 { 522 // GDateYear g_date_get_year (const GDate *date); 523 return g_date_get_year(gDate); 524 } 525 526 /** 527 * Returns the Julian day or "serial number" of the GDate. The 528 * Julian day is simply the number of days since January 1, Year 1; i.e., 529 * January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2, 530 * etc. The date must be valid. 531 * Returns: Julian day 532 */ 533 public uint getJulian() 534 { 535 // guint32 g_date_get_julian (const GDate *date); 536 return g_date_get_julian(gDate); 537 } 538 539 /** 540 * Returns the day of the week for a GDate. The date must be valid. 541 * Returns: day of the week as a GDateWeekday. 542 */ 543 public GDateWeekday getWeekday() 544 { 545 // GDateWeekday g_date_get_weekday (const GDate *date); 546 return g_date_get_weekday(gDate); 547 } 548 549 /** 550 * Returns the day of the year, where Jan 1 is the first day of the 551 * year. The date must be valid. 552 * Returns: day of the year 553 */ 554 public uint getDayOfYear() 555 { 556 // guint g_date_get_day_of_year (const GDate *date); 557 return g_date_get_day_of_year(gDate); 558 } 559 560 /** 561 * Returns the number of days in a month, taking leap 562 * years into account. 563 * Params: 564 * month = month 565 * year = year 566 * Returns: number of days in month during the year 567 */ 568 public static ubyte getDaysInMonth(GDateMonth month, GDateYear year) 569 { 570 // guint8 g_date_get_days_in_month (GDateMonth month, GDateYear year); 571 return g_date_get_days_in_month(month, year); 572 } 573 574 /** 575 * Returns TRUE if the date is on the first of a month. 576 * The date must be valid. 577 * Returns: TRUE if the date is the first of the month 578 */ 579 public int isFirstOfMonth() 580 { 581 // gboolean g_date_is_first_of_month (const GDate *date); 582 return g_date_is_first_of_month(gDate); 583 } 584 585 /** 586 * Returns TRUE if the date is the last day of the month. 587 * The date must be valid. 588 * Returns: TRUE if the date is the last day of the month 589 */ 590 public int isLastOfMonth() 591 { 592 // gboolean g_date_is_last_of_month (const GDate *date); 593 return g_date_is_last_of_month(gDate); 594 } 595 596 /** 597 * Returns TRUE if the year is a leap year. 598 * [5] 599 * Params: 600 * year = year to check 601 * Returns: TRUE if the year is a leap year 602 */ 603 public static int isLeapYear(GDateYear year) 604 { 605 // gboolean g_date_is_leap_year (GDateYear year); 606 return g_date_is_leap_year(year); 607 } 608 609 /** 610 * Returns the week of the year, where weeks are understood to start on 611 * Monday. If the date is before the first Monday of the year, return 612 * 0. The date must be valid. 613 * Returns: week of the year 614 */ 615 public uint getMondayWeekOfYear() 616 { 617 // guint g_date_get_monday_week_of_year (const GDate *date); 618 return g_date_get_monday_week_of_year(gDate); 619 } 620 621 /** 622 * Returns the number of weeks in the year, where weeks 623 * are taken to start on Monday. Will be 52 or 53. The 624 * date must be valid. (Years always have 52 7-day periods, 625 * plus 1 or 2 extra days depending on whether it's a leap 626 * year. This function is basically telling you how many 627 * Mondays are in the year, i.e. there are 53 Mondays if 628 * one of the extra days happens to be a Monday.) 629 * Params: 630 * year = a year 631 * Returns: number of Mondays in the year 632 */ 633 public static ubyte getMondayWeeksInYear(GDateYear year) 634 { 635 // guint8 g_date_get_monday_weeks_in_year (GDateYear year); 636 return g_date_get_monday_weeks_in_year(year); 637 } 638 639 /** 640 * Returns the week of the year during which this date falls, if weeks 641 * are understood to being on Sunday. The date must be valid. Can return 642 * 0 if the day is before the first Sunday of the year. 643 * Returns: week number 644 */ 645 public uint getSundayWeekOfYear() 646 { 647 // guint g_date_get_sunday_week_of_year (const GDate *date); 648 return g_date_get_sunday_week_of_year(gDate); 649 } 650 651 /** 652 * Returns the number of weeks in the year, where weeks 653 * are taken to start on Sunday. Will be 52 or 53. The 654 * date must be valid. (Years always have 52 7-day periods, 655 * plus 1 or 2 extra days depending on whether it's a leap 656 * year. This function is basically telling you how many 657 * Sundays are in the year, i.e. there are 53 Sundays if 658 * one of the extra days happens to be a Sunday.) 659 * Params: 660 * year = year to count weeks in 661 * Returns: the number of weeks in year 662 */ 663 public static ubyte getSundayWeeksInYear(GDateYear year) 664 { 665 // guint8 g_date_get_sunday_weeks_in_year (GDateYear year); 666 return g_date_get_sunday_weeks_in_year(year); 667 } 668 669 /** 670 * Returns the week of the year, where weeks are interpreted according 671 * to ISO 8601. 672 * Since 2.6 673 * Returns: ISO 8601 week number of the year. 674 */ 675 public uint getIso8601_WeekOfYear() 676 { 677 // guint g_date_get_iso8601_week_of_year (const GDate *date); 678 return g_date_get_iso8601_week_of_year(gDate); 679 } 680 681 /** 682 * Generates a printed representation of the date, in a 683 * locale-specific way. 684 * Works just like the platform's C library strftime() function, 685 * but only accepts date-related formats; time-related formats 686 * give undefined results. Date must be valid. Unlike strftime() 687 * (which uses the locale encoding), works on a UTF-8 format 688 * string and stores a UTF-8 result. 689 * This function does not provide any conversion specifiers in 690 * addition to those implemented by the platform's C library. 691 * For example, don't expect that using g_date_strftime() would 692 * make the %F provided by the C99 strftime() work on Windows 693 * where the C library only complies to C89. 694 * Params: 695 * s = destination buffer 696 * format = format string 697 * date = valid GDate 698 * Returns: number of characters written to the buffer, or 0 the buffer was too small 699 */ 700 public static gsize strftime(char[] s, string format, Date date) 701 { 702 // gsize g_date_strftime (gchar *s, gsize slen, const gchar *format, const GDate *date); 703 return g_date_strftime(s.ptr, cast(int) s.length, Str.toStringz(format), (date is null) ? null : date.getDateStruct()); 704 } 705 706 /** 707 * Fills in the date-related bits of a struct tm 708 * using the date value. Initializes the non-date parts with something 709 * sane but meaningless. 710 * Params: 711 * tm = struct tm to fill 712 */ 713 public void toStructTm(void* tm) 714 { 715 // void g_date_to_struct_tm (const GDate *date, struct tm *tm); 716 g_date_to_struct_tm(gDate, tm); 717 } 718 719 /** 720 * Returns TRUE if the GDate represents an existing day. The date must not 721 * contain garbage; it should have been initialized with g_date_clear() 722 * if it wasn't allocated by one of the g_date_new() variants. 723 * Returns: Whether the date is valid 724 */ 725 public int valid() 726 { 727 // gboolean g_date_valid (const GDate *date); 728 return g_date_valid(gDate); 729 } 730 731 /** 732 * Returns TRUE if the day of the month is valid (a day is valid if it's 733 * between 1 and 31 inclusive). 734 * Params: 735 * day = day to check 736 * Returns: TRUE if the day is valid 737 */ 738 public static int validDay(GDateDay day) 739 { 740 // gboolean g_date_valid_day (GDateDay day); 741 return g_date_valid_day(day); 742 } 743 744 /** 745 * Returns TRUE if the month value is valid. The 12 GDateMonth 746 * enumeration values are the only valid months. 747 * Params: 748 * month = month 749 * Returns: TRUE if the month is valid 750 */ 751 public static int validMonth(GDateMonth month) 752 { 753 // gboolean g_date_valid_month (GDateMonth month); 754 return g_date_valid_month(month); 755 } 756 757 /** 758 * Returns TRUE if the year is valid. Any year greater than 0 is valid, 759 * though there is a 16-bit limit to what GDate will understand. 760 * Params: 761 * year = year 762 * Returns: TRUE if the year is valid 763 */ 764 public static int validYear(GDateYear year) 765 { 766 // gboolean g_date_valid_year (GDateYear year); 767 return g_date_valid_year(year); 768 } 769 770 /** 771 * Returns TRUE if the day-month-year triplet forms a valid, existing day 772 * in the range of days GDate understands (Year 1 or later, no more than 773 * a few thousand years in the future). 774 * Params: 775 * day = day 776 * month = month 777 * year = year 778 * Returns: TRUE if the date is a valid one 779 */ 780 public static int validDmy(GDateDay day, GDateMonth month, GDateYear year) 781 { 782 // gboolean g_date_valid_dmy (GDateDay day, GDateMonth month, GDateYear year); 783 return g_date_valid_dmy(day, month, year); 784 } 785 786 /** 787 * Returns TRUE if the Julian day is valid. Anything greater than zero 788 * is basically a valid Julian, though there is a 32-bit limit. 789 * Params: 790 * julianDate = Julian day to check 791 * Returns: TRUE if the Julian day is valid 792 */ 793 public static int validJulian(uint julianDate) 794 { 795 // gboolean g_date_valid_julian (guint32 julian_date); 796 return g_date_valid_julian(julianDate); 797 } 798 799 /** 800 * Returns TRUE if the weekday is valid. The seven GDateWeekday enumeration 801 * values are the only valid weekdays. 802 * Params: 803 * weekday = weekday 804 * Returns: TRUE if the weekday is valid [5] For the purposes of this function, leap year is every year divisible by 4 unless that year is divisible by 100. If it is divisible by 100 it would be a leap year only if that year is also divisible by 400. 805 */ 806 public static int validWeekday(GDateWeekday weekday) 807 { 808 // gboolean g_date_valid_weekday (GDateWeekday weekday); 809 return g_date_valid_weekday(weekday); 810 } 811 }