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