1//--------------------------------------------------------------------------- 2// This file is generated by wxPython's SIP generator. Do not edit by hand. 3// 4// Copyright: (c) 2018 by Total Control Software 5// License: wxWindows License 6// 7// This file will be included by _core.sip 8// 9//--------------------------------------------------------------------------- 10 11//--------------------------------------------------------------------------- 12 13const char* wxDefaultTimeSpanFormat; 14 15const char* wxDefaultDateTimeFormat; 16 17class wxDateTime 18{ 19 %Docstring 20 DateTime() 21 DateTime(date) 22 DateTime(day, month, year=Inv_Year, hour=0, minute=0, second=0, millisec=0) 23 24 wxDateTime class represents an absolute moment in time. 25 %End 26 %TypeHeaderCode 27 #include <wx/datetime.h> 28 %End 29 30public: 31 enum TZ 32 { 33 Local, 34 GMT_12, 35 GMT_11, 36 GMT_10, 37 GMT_9, 38 GMT_8, 39 GMT_7, 40 GMT_6, 41 GMT_5, 42 GMT_4, 43 GMT_3, 44 GMT_2, 45 GMT_1, 46 GMT0, 47 GMT1, 48 GMT2, 49 GMT3, 50 GMT4, 51 GMT5, 52 GMT6, 53 GMT7, 54 GMT8, 55 GMT9, 56 GMT10, 57 GMT11, 58 GMT12, 59 GMT13, 60 WET, 61 WEST, 62 CET, 63 CEST, 64 EET, 65 EEST, 66 MSK, 67 MSD, 68 AST, 69 ADT, 70 EST, 71 EDT, 72 CST, 73 CDT, 74 MST, 75 MDT, 76 PST, 77 PDT, 78 HST, 79 AKST, 80 AKDT, 81 A_WST, 82 A_CST, 83 A_EST, 84 A_ESST, 85 NZST, 86 NZDT, 87 UTC 88 }; 89 90 enum Calendar 91 { 92 Gregorian, 93 Julian 94 }; 95 96 enum Country 97 { 98 Country_Unknown, 99 Country_Default, 100 Country_WesternEurope_Start, 101 Country_EEC, 102 France, 103 Germany, 104 UK, 105 Country_WesternEurope_End, 106 Russia, 107 USA 108 }; 109 110 enum Month 111 { 112 Jan, 113 Feb, 114 Mar, 115 Apr, 116 May, 117 Jun, 118 Jul, 119 Aug, 120 Sep, 121 Oct, 122 Nov, 123 Dec, 124 Inv_Month 125 }; 126 127 enum WeekDay 128 { 129 Sun, 130 Mon, 131 Tue, 132 Wed, 133 Thu, 134 Fri, 135 Sat, 136 Inv_WeekDay 137 }; 138 139 enum Year 140 { 141 Inv_Year 142 }; 143 144 enum NameFlags 145 { 146 Name_Full, 147 Name_Abbr 148 }; 149 150 enum WeekFlags 151 { 152 Default_First, 153 Monday_First, 154 Sunday_First 155 }; 156 157public: 158 class TimeZone 159 { 160 %Docstring 161 TimeZone(tz) 162 TimeZone(offset=0) 163 164 Class representing a time zone. 165 %End 166 %TypeHeaderCode 167 #include <wx/datetime.h> 168 %End 169 170 public: 171 TimeZone( 172 wxDateTime::TZ tz 173 ); 174 175 TimeZone( 176 long offset = 0 177 ); 178 179 long GetOffset() const; 180 %Docstring 181 GetOffset() -> long 182 183 Return the offset of this time zone from UTC, in seconds. 184 %End 185 186 static 187 wxDateTime::TimeZone Make( 188 long offset 189 ); 190 %Docstring 191 Make(offset) -> DateTime.TimeZone 192 193 Create a time zone with the given offset in seconds. 194 %End 195 196 public: 197 198 199 %Property(name=Offset, get=GetOffset) 200 }; // end of class TimeZone 201 202 203public: 204 struct Tm 205 { 206 %Docstring 207 Contains broken down date-time representation. 208 %End 209 %TypeHeaderCode 210 #include <wx/datetime.h> 211 %End 212 213 unsigned short msec; 214 215 unsigned short sec; 216 217 unsigned short min; 218 219 unsigned short hour; 220 221 unsigned short mday; 222 223 unsigned short yday; 224 225 wxDateTime::Month mon; 226 227 int year; 228 229 bool IsValid() const; 230 %Docstring 231 IsValid() -> bool 232 233 Check if the given date/time is valid (in Gregorian calendar). 234 %End 235 236 wxDateTime::WeekDay GetWeekDay(); 237 %Docstring 238 GetWeekDay() -> DateTime.WeekDay 239 240 Return the week day corresponding to this date. 241 %End 242 243 public: 244 245 246 %Property(name=WeekDay, get=GetWeekDay) 247 }; // end of class Tm 248 249 250 wxDateTime(); 251 252 wxDateTime( 253 const wxDateTime & date 254 ); 255 256 wxDateTime( 257 unsigned short day, 258 wxDateTime::Month month, 259 int year = Inv_Year, 260 unsigned short hour = 0, 261 unsigned short minute = 0, 262 unsigned short second = 0, 263 unsigned short millisec = 0 264 ); 265 266 wxDateTime & ResetTime(); 267 %Docstring 268 ResetTime() -> DateTime 269 270 Reset time to midnight (00:00:00) without changing the date. 271 %End 272 273 wxDateTime & Set( 274 unsigned short day, 275 wxDateTime::Month month, 276 int year = Inv_Year, 277 unsigned short hour = 0, 278 unsigned short minute = 0, 279 unsigned short second = 0, 280 unsigned short millisec = 0 281 ); 282 %Docstring 283 Set(day, month, year=Inv_Year, hour=0, minute=0, second=0, millisec=0) -> DateTime 284 285 Sets the date and time from the parameters. 286 %End 287 288 wxDateTime & Set( 289 unsigned short hour, 290 unsigned short minute = 0, 291 unsigned short second = 0, 292 unsigned short millisec = 0 293 ) /PyName=SetHMS/; 294 %Docstring 295 SetHMS(hour, minute=0, second=0, millisec=0) -> DateTime 296 297 Sets the date to be equal to Today() and the time from supplied 298 parameters. 299 %End 300 301 wxDateTime & Set( 302 double jdn 303 ) /PyName=SetJDN/; 304 %Docstring 305 SetJDN(jdn) -> DateTime 306 307 Sets the date from the so-called Julian Day Number. 308 %End 309 310 wxDateTime & Set( 311 time_t timet 312 ) /PyName=SetTimeT/; 313 %Docstring 314 SetTimeT(timet) -> DateTime 315 316 Constructs the object from timet value holding the number of seconds 317 since Jan 1, 1970 UTC. 318 %End 319 320 wxDateTime & Set( 321 const Tm & tm 322 ) /PyName=SetTm/; 323 %Docstring 324 SetTm(tm) -> DateTime 325 326 Sets the date and time from the broken down representation in the 327 wxDateTime::Tm structure. 328 %End 329 330 wxDateTime & SetDay( 331 unsigned short day 332 ); 333 %Docstring 334 SetDay(day) -> DateTime 335 336 Sets the day without changing other date components. 337 %End 338 339 wxDateTime & SetFromDOS( 340 unsigned long ddt 341 ); 342 %Docstring 343 SetFromDOS(ddt) -> DateTime 344 345 Sets the date from the date and time in DOS format. 346 %End 347 348 wxDateTime & SetHour( 349 unsigned short hour 350 ); 351 %Docstring 352 SetHour(hour) -> DateTime 353 354 Sets the hour without changing other date components. 355 %End 356 357 wxDateTime & SetMillisecond( 358 unsigned short millisecond 359 ); 360 %Docstring 361 SetMillisecond(millisecond) -> DateTime 362 363 Sets the millisecond without changing other date components. 364 %End 365 366 wxDateTime & SetMinute( 367 unsigned short minute 368 ); 369 %Docstring 370 SetMinute(minute) -> DateTime 371 372 Sets the minute without changing other date components. 373 %End 374 375 wxDateTime & SetMonth( 376 wxDateTime::Month month 377 ); 378 %Docstring 379 SetMonth(month) -> DateTime 380 381 Sets the month without changing other date components. 382 %End 383 384 wxDateTime & SetSecond( 385 unsigned short second 386 ); 387 %Docstring 388 SetSecond(second) -> DateTime 389 390 Sets the second without changing other date components. 391 %End 392 393 wxDateTime & SetToCurrent(); 394 %Docstring 395 SetToCurrent() -> DateTime 396 397 Sets the date and time of to the current values. 398 %End 399 400 wxDateTime & SetYear( 401 int year 402 ); 403 %Docstring 404 SetYear(year) -> DateTime 405 406 Sets the year without changing other date components. 407 %End 408 409 unsigned long GetAsDOS() const; 410 %Docstring 411 GetAsDOS() -> unsignedlong 412 413 Returns the date and time in DOS format. 414 %End 415 416 int GetCentury( 417 const TimeZone & tz = Local 418 ) const; 419 %Docstring 420 GetCentury(tz=Local) -> int 421 422 Returns the century of this date. 423 %End 424 425 wxDateTime GetDateOnly() const; 426 %Docstring 427 GetDateOnly() -> DateTime 428 429 Returns the object having the same date component as this one but time 430 of 00:00:00. 431 %End 432 433 unsigned short GetDay( 434 const TimeZone & tz = Local 435 ) const; 436 %Docstring 437 GetDay(tz=Local) -> unsignedshort 438 439 Returns the day in the given timezone (local one by default). 440 %End 441 442 unsigned short GetDayOfYear( 443 const TimeZone & tz = Local 444 ) const; 445 %Docstring 446 GetDayOfYear(tz=Local) -> unsignedshort 447 448 Returns the day of the year (in 1-366 range) in the given timezone 449 (local one by default). 450 %End 451 452 unsigned short GetHour( 453 const TimeZone & tz = Local 454 ) const; 455 %Docstring 456 GetHour(tz=Local) -> unsignedshort 457 458 Returns the hour in the given timezone (local one by default). 459 %End 460 461 unsigned short GetMillisecond( 462 const TimeZone & tz = Local 463 ) const; 464 %Docstring 465 GetMillisecond(tz=Local) -> unsignedshort 466 467 Returns the milliseconds in the given timezone (local one by default). 468 %End 469 470 unsigned short GetMinute( 471 const TimeZone & tz = Local 472 ) const; 473 %Docstring 474 GetMinute(tz=Local) -> unsignedshort 475 476 Returns the minute in the given timezone (local one by default). 477 %End 478 479 wxDateTime::Month GetMonth( 480 const TimeZone & tz = Local 481 ) const; 482 %Docstring 483 GetMonth(tz=Local) -> DateTime.Month 484 485 Returns the month in the given timezone (local one by default). 486 %End 487 488 unsigned short GetSecond( 489 const TimeZone & tz = Local 490 ) const; 491 %Docstring 492 GetSecond(tz=Local) -> unsignedshort 493 494 Returns the seconds in the given timezone (local one by default). 495 %End 496 497 time_t GetTicks() const; 498 %Docstring 499 GetTicks() -> time_t 500 501 Returns the number of seconds since Jan 1, 1970 UTC. 502 %End 503 504 wxDateTime::Tm GetTm( 505 const TimeZone & tz = Local 506 ) const; 507 %Docstring 508 GetTm(tz=Local) -> DateTime.Tm 509 510 Returns broken down representation of the date and time. 511 %End 512 513 wxDateTime::WeekDay GetWeekDay( 514 const TimeZone & tz = Local 515 ) const; 516 %Docstring 517 GetWeekDay(tz=Local) -> DateTime.WeekDay 518 GetWeekDay(weekday, n=1, month=Inv_Month, year=Inv_Year) -> DateTime 519 520 Returns the week day in the given timezone (local one by default). 521 %End 522 523 wxDateTime GetWeekDay( 524 wxDateTime::WeekDay weekday, 525 int n = 1, 526 wxDateTime::Month month = Inv_Month, 527 int year = Inv_Year 528 ) const; 529 530 unsigned short GetWeekOfMonth( 531 WeekFlags flags = Monday_First, 532 const TimeZone & tz = Local 533 ) const; 534 %Docstring 535 GetWeekOfMonth(flags=Monday_First, tz=Local) -> unsignedshort 536 537 Returns the ordinal number of the week in the month (in 1-5 range). 538 %End 539 540 unsigned short GetWeekOfYear( 541 WeekFlags flags = Monday_First, 542 const TimeZone & tz = Local 543 ) const; 544 %Docstring 545 GetWeekOfYear(flags=Monday_First, tz=Local) -> unsignedshort 546 547 Returns the number of the week of the year this date is in. 548 %End 549 550 int GetYear( 551 const TimeZone & tz = Local 552 ) const; 553 %Docstring 554 GetYear(tz=Local) -> int 555 556 Returns the year in the given timezone (local one by default). 557 %End 558 559 bool IsValid() const; 560 %Docstring 561 IsValid() -> bool 562 563 Returns true if the object represents a valid time moment. 564 %End 565 566 bool IsWorkDay( 567 Country country = Country_Default 568 ) const; 569 %Docstring 570 IsWorkDay(country=Country_Default) -> bool 571 572 Returns true is this day is not a holiday in the given country. 573 %End 574 575 bool IsEarlierThan( 576 const wxDateTime & datetime 577 ) const; 578 %Docstring 579 IsEarlierThan(datetime) -> bool 580 581 Returns true if this date precedes the given one. 582 %End 583 584 bool IsEqualTo( 585 const wxDateTime & datetime 586 ) const; 587 %Docstring 588 IsEqualTo(datetime) -> bool 589 590 Returns true if the two dates are strictly identical. 591 %End 592 593 bool IsEqualUpTo( 594 const wxDateTime & dt, 595 const wxTimeSpan & ts 596 ) const; 597 %Docstring 598 IsEqualUpTo(dt, ts) -> bool 599 600 Returns true if the date is equal to another one up to the given time 601 interval, i.e. if the absolute difference between the two dates is 602 less than this interval. 603 %End 604 605 bool IsLaterThan( 606 const wxDateTime & datetime 607 ) const; 608 %Docstring 609 IsLaterThan(datetime) -> bool 610 611 Returns true if this date is later than the given one. 612 %End 613 614 bool IsSameDate( 615 const wxDateTime & dt 616 ) const; 617 %Docstring 618 IsSameDate(dt) -> bool 619 620 Returns true if the date is the same without comparing the time parts. 621 %End 622 623 bool IsSameTime( 624 const wxDateTime & dt 625 ) const; 626 %Docstring 627 IsSameTime(dt) -> bool 628 629 Returns true if the time is the same (although dates may differ). 630 %End 631 632 bool IsStrictlyBetween( 633 const wxDateTime & t1, 634 const wxDateTime & t2 635 ) const; 636 %Docstring 637 IsStrictlyBetween(t1, t2) -> bool 638 639 Returns true if this date lies strictly between the two given dates. 640 %End 641 642 bool IsBetween( 643 const wxDateTime & t1, 644 const wxDateTime & t2 645 ) const; 646 %Docstring 647 IsBetween(t1, t2) -> bool 648 649 Returns true if IsStrictlyBetween() is true or if the date is equal to 650 one of the limit values. 651 %End 652 653 wxDateTime & Add( 654 const wxDateSpan & diff 655 ); 656 %Docstring 657 Add(diff) -> DateTime 658 Add(diff) -> DateTime 659 660 Adds the given date span to this object. 661 %End 662 663 wxDateTime & Add( 664 const wxTimeSpan & diff 665 ); 666 667 wxDateTime & Subtract( 668 const wxTimeSpan & diff 669 ); 670 %Docstring 671 Subtract(diff) -> DateTime 672 Subtract(diff) -> DateTime 673 Subtract(dt) -> TimeSpan 674 675 Subtracts the given time span from this object. 676 %End 677 678 wxDateTime & Subtract( 679 const wxDateSpan & diff 680 ); 681 682 wxTimeSpan Subtract( 683 const wxDateTime & dt 684 ) const; 685 686 wxDateSpan DiffAsDateSpan( 687 const wxDateTime & dt 688 ) const; 689 %Docstring 690 DiffAsDateSpan(dt) -> DateSpan 691 692 Returns the difference between this object and dt as a wxDateSpan. 693 %End 694 695 wxString Format( 696 const wxString & format = wxDefaultDateTimeFormat, 697 const TimeZone & tz = Local 698 ) const; 699 %Docstring 700 Format(format=DefaultDateTimeFormat, tz=Local) -> String 701 702 This function does the same as the standard ANSI C strftime(3) 703 function 704 (http://www.cplusplus.com/reference/clibrary/ctime/strftime.html). 705 %End 706 707 wxString FormatDate() const; 708 %Docstring 709 FormatDate() -> String 710 711 Identical to calling Format() with "%x" argument (which means 712 "preferred date representation for the current locale"). 713 %End 714 715 wxString FormatISOCombined( 716 char sep = 'T' 717 ) const; 718 %Docstring 719 FormatISOCombined(sep='T') -> String 720 721 Returns the combined date-time representation in the ISO 8601 format 722 "YYYY-MM-DDTHH:MM:SS". 723 %End 724 725 wxString FormatISODate() const; 726 %Docstring 727 FormatISODate() -> String 728 729 This function returns the date representation in the ISO 8601 format 730 "YYYY-MM-DD". 731 %End 732 733 wxString FormatISOTime() const; 734 %Docstring 735 FormatISOTime() -> String 736 737 This function returns the time representation in the ISO 8601 format 738 "HH:MM:SS". 739 %End 740 741 wxString FormatTime() const; 742 %Docstring 743 FormatTime() -> String 744 745 Identical to calling Format() with "%X" argument (which means 746 "preferred time representation for the current locale"). 747 %End 748 749 int ParseDate( 750 const wxString & date 751 ); 752 %Docstring 753 ParseDate(date) -> int 754 755 This function is like ParseDateTime(), but it only allows the date to 756 be specified. 757 %End 758 %MethodCode 759 PyErr_Clear(); 760 Py_BEGIN_ALLOW_THREADS 761 sipRes = _wxDateTime_ParseDate(sipCpp, date); 762 Py_END_ALLOW_THREADS 763 if (PyErr_Occurred()) sipIsErr = 1; 764 %End 765 %TypeCode 766 int _wxDateTime_ParseDate(wxDateTime* self, const wxString *date) 767 { 768 wxString::const_iterator begin = date->begin(); 769 wxString::const_iterator end; 770 if (! self->ParseDate(*date, &end)) 771 return -1; 772 return end - begin; 773 } 774 %End 775 776 int ParseDateTime( 777 const wxString & datetime 778 ); 779 %Docstring 780 ParseDateTime(datetime) -> int 781 782 Parses the string datetime containing the date and time in free 783 format. 784 %End 785 %MethodCode 786 PyErr_Clear(); 787 Py_BEGIN_ALLOW_THREADS 788 sipRes = _wxDateTime_ParseDateTime(sipCpp, datetime); 789 Py_END_ALLOW_THREADS 790 if (PyErr_Occurred()) sipIsErr = 1; 791 %End 792 %TypeCode 793 int _wxDateTime_ParseDateTime(wxDateTime* self, const wxString *datetime) 794 { 795 wxString::const_iterator begin = datetime->begin(); 796 wxString::const_iterator end; 797 if (! self->ParseDateTime(*datetime, &end)) 798 return -1; 799 return end - begin; 800 } 801 %End 802 803 int ParseFormat( 804 const wxString & date, 805 const wxString & format, 806 const wxDateTime & dateDef 807 ); 808 %Docstring 809 ParseFormat(date, format, dateDef) -> int 810 ParseFormat(date, format) -> int 811 ParseFormat(date) -> int 812 813 This function parses the string date according to the given format. 814 %End 815 %MethodCode 816 PyErr_Clear(); 817 Py_BEGIN_ALLOW_THREADS 818 sipRes = _wxDateTime_ParseFormat(sipCpp, date, format, dateDef); 819 Py_END_ALLOW_THREADS 820 if (PyErr_Occurred()) sipIsErr = 1; 821 %End 822 %TypeCode 823 int _wxDateTime_ParseFormat(wxDateTime* self, const wxString *date, const wxString *format, const wxDateTime *dateDef) 824 { 825 wxString::const_iterator begin = date->begin(); 826 wxString::const_iterator end; 827 if (! self->ParseFormat(*date, *format, *dateDef, &end)) 828 return -1; 829 return end - begin; 830 } 831 %End 832 833 int ParseFormat( 834 const wxString & date, 835 const wxString & format 836 ); 837 %Docstring 838 ParseFormat(date, format) -> int 839 840 This version of the :meth:`ParseFormat` method works the same, but 841 with missing values filled in from :meth:`Today`. 842 %End 843 %MethodCode 844 PyErr_Clear(); 845 Py_BEGIN_ALLOW_THREADS 846 sipRes = _wxDateTime_ParseFormat(sipCpp, date, format); 847 Py_END_ALLOW_THREADS 848 if (PyErr_Occurred()) sipIsErr = 1; 849 %End 850 %TypeCode 851 int _wxDateTime_ParseFormat(wxDateTime* self, const wxString *date, const wxString *format) 852 { 853 wxString::const_iterator begin = date->begin(); 854 wxString::const_iterator end; 855 if (! self->ParseFormat(*date, *format, &end)) 856 return -1; 857 return end - begin; 858 } 859 %End 860 861 int ParseFormat( 862 const wxString & date 863 ); 864 %Docstring 865 ParseFormat(date) -> int 866 867 This version uses "%c" as the format code, which is the same default 868 used by :meth:`Format`. 869 %End 870 %MethodCode 871 PyErr_Clear(); 872 Py_BEGIN_ALLOW_THREADS 873 sipRes = _wxDateTime_ParseFormat(sipCpp, date); 874 Py_END_ALLOW_THREADS 875 if (PyErr_Occurred()) sipIsErr = 1; 876 %End 877 %TypeCode 878 int _wxDateTime_ParseFormat(wxDateTime* self, const wxString *date) 879 { 880 wxString::const_iterator begin = date->begin(); 881 wxString::const_iterator end; 882 if (! self->ParseFormat(*date, &end)) 883 return -1; 884 return end - begin; 885 } 886 %End 887 888 bool ParseISOCombined( 889 const wxString & date, 890 char sep = 'T' 891 ); 892 %Docstring 893 ParseISOCombined(date, sep='T') -> bool 894 895 This function parses the string containing the date and time in ISO 896 8601 combined format "YYYY-MM-DDTHH:MM:SS". 897 %End 898 899 bool ParseISODate( 900 const wxString & date 901 ); 902 %Docstring 903 ParseISODate(date) -> bool 904 905 This function parses the date in ISO 8601 format "YYYY-MM-DD". 906 %End 907 908 bool ParseISOTime( 909 const wxString & date 910 ); 911 %Docstring 912 ParseISOTime(date) -> bool 913 914 This function parses the time in ISO 8601 format "HH:MM:SS". 915 %End 916 917 int ParseRfc822Date( 918 const wxString & date 919 ); 920 %Docstring 921 ParseRfc822Date(date) -> int 922 923 Parses the string date looking for a date formatted according to the 924 RFC 822 in it. 925 %End 926 %MethodCode 927 PyErr_Clear(); 928 Py_BEGIN_ALLOW_THREADS 929 sipRes = _wxDateTime_ParseRfc822Date(sipCpp, date); 930 Py_END_ALLOW_THREADS 931 if (PyErr_Occurred()) sipIsErr = 1; 932 %End 933 %TypeCode 934 int _wxDateTime_ParseRfc822Date(wxDateTime* self, const wxString *date) 935 { 936 wxString::const_iterator begin = date->begin(); 937 wxString::const_iterator end; 938 if (! self->ParseRfc822Date(*date, &end)) 939 return -1; 940 return end - begin; 941 } 942 %End 943 944 int ParseTime( 945 const wxString & time 946 ); 947 %Docstring 948 ParseTime(time) -> int 949 950 This functions is like ParseDateTime(), but only allows the time to be 951 specified in the input string. 952 %End 953 %MethodCode 954 PyErr_Clear(); 955 Py_BEGIN_ALLOW_THREADS 956 sipRes = _wxDateTime_ParseTime(sipCpp, time); 957 Py_END_ALLOW_THREADS 958 if (PyErr_Occurred()) sipIsErr = 1; 959 %End 960 %TypeCode 961 int _wxDateTime_ParseTime(wxDateTime* self, const wxString *time) 962 { 963 wxString::const_iterator begin = time->begin(); 964 wxString::const_iterator end; 965 if (! self->ParseTime(*time, &end)) 966 return -1; 967 return end - begin; 968 } 969 %End 970 971 wxDateTime GetLastMonthDay( 972 wxDateTime::Month month = Inv_Month, 973 int year = Inv_Year 974 ) const; 975 %Docstring 976 GetLastMonthDay(month=Inv_Month, year=Inv_Year) -> DateTime 977 978 Returns the copy of this object to which SetToLastMonthDay() was 979 applied. 980 %End 981 982 wxDateTime GetLastWeekDay( 983 wxDateTime::WeekDay weekday, 984 wxDateTime::Month month = Inv_Month, 985 int year = Inv_Year 986 ); 987 %Docstring 988 GetLastWeekDay(weekday, month=Inv_Month, year=Inv_Year) -> DateTime 989 990 Returns the copy of this object to which SetToLastWeekDay() was 991 applied. 992 %End 993 994 wxDateTime GetNextWeekDay( 995 wxDateTime::WeekDay weekday 996 ) const; 997 %Docstring 998 GetNextWeekDay(weekday) -> DateTime 999 1000 Returns the copy of this object to which SetToNextWeekDay() was 1001 applied. 1002 %End 1003 1004 wxDateTime GetPrevWeekDay( 1005 wxDateTime::WeekDay weekday 1006 ) const; 1007 %Docstring 1008 GetPrevWeekDay(weekday) -> DateTime 1009 1010 Returns the copy of this object to which SetToPrevWeekDay() was 1011 applied. 1012 %End 1013 1014 wxDateTime GetWeekDayInSameWeek( 1015 wxDateTime::WeekDay weekday, 1016 WeekFlags flags = Monday_First 1017 ) const; 1018 %Docstring 1019 GetWeekDayInSameWeek(weekday, flags=Monday_First) -> DateTime 1020 1021 Returns the copy of this object to which SetToWeekDayInSameWeek() was 1022 applied. 1023 %End 1024 1025 wxDateTime GetYearDay( 1026 unsigned short yday 1027 ) const; 1028 %Docstring 1029 GetYearDay(yday) -> DateTime 1030 1031 Returns the copy of this object to which SetToYearDay() was applied. 1032 %End 1033 1034 wxDateTime & SetToLastMonthDay( 1035 wxDateTime::Month month = Inv_Month, 1036 int year = Inv_Year 1037 ); 1038 %Docstring 1039 SetToLastMonthDay(month=Inv_Month, year=Inv_Year) -> DateTime 1040 1041 Sets the date to the last day in the specified month (the current one 1042 by default). 1043 %End 1044 1045 bool SetToLastWeekDay( 1046 wxDateTime::WeekDay weekday, 1047 wxDateTime::Month month = Inv_Month, 1048 int year = Inv_Year 1049 ); 1050 %Docstring 1051 SetToLastWeekDay(weekday, month=Inv_Month, year=Inv_Year) -> bool 1052 1053 The effect of calling this function is the same as of calling 1054 SetToWeekDay(-1, weekday, month, year). 1055 %End 1056 1057 wxDateTime & SetToNextWeekDay( 1058 wxDateTime::WeekDay weekday 1059 ); 1060 %Docstring 1061 SetToNextWeekDay(weekday) -> DateTime 1062 1063 Sets the date so that it will be the first weekday following the 1064 current date. 1065 %End 1066 1067 wxDateTime & SetToPrevWeekDay( 1068 wxDateTime::WeekDay weekday 1069 ); 1070 %Docstring 1071 SetToPrevWeekDay(weekday) -> DateTime 1072 1073 Sets the date so that it will be the last weekday before the current 1074 date. 1075 %End 1076 1077 bool SetToWeekDay( 1078 wxDateTime::WeekDay weekday, 1079 int n = 1, 1080 wxDateTime::Month month = Inv_Month, 1081 int year = Inv_Year 1082 ); 1083 %Docstring 1084 SetToWeekDay(weekday, n=1, month=Inv_Month, year=Inv_Year) -> bool 1085 1086 Sets the date to the n-th weekday in the given month of the given year 1087 (the current month and year are used by default). 1088 %End 1089 1090 wxDateTime & SetToWeekDayInSameWeek( 1091 wxDateTime::WeekDay weekday, 1092 WeekFlags flags = Monday_First 1093 ); 1094 %Docstring 1095 SetToWeekDayInSameWeek(weekday, flags=Monday_First) -> DateTime 1096 1097 Adjusts the date so that it will still lie in the same week as before, 1098 but its week day will be the given one. 1099 %End 1100 1101 wxDateTime & SetToYearDay( 1102 unsigned short yday 1103 ); 1104 %Docstring 1105 SetToYearDay(yday) -> DateTime 1106 1107 Sets the date to the day number yday in the same year (i.e. unlike the 1108 other functions, this one does not use the current year). 1109 %End 1110 1111 double GetJDN() const; 1112 %Docstring 1113 GetJDN() -> double 1114 1115 Synonym for GetJulianDayNumber(). 1116 %End 1117 1118 double GetJulianDayNumber() const; 1119 %Docstring 1120 GetJulianDayNumber() -> double 1121 1122 Returns the JDN corresponding to this date. 1123 %End 1124 1125 double GetMJD() const; 1126 %Docstring 1127 GetMJD() -> double 1128 1129 Synonym for GetModifiedJulianDayNumber(). 1130 %End 1131 1132 double GetModifiedJulianDayNumber() const; 1133 %Docstring 1134 GetModifiedJulianDayNumber() -> double 1135 1136 Returns the "Modified Julian Day Number" (MJD) which is, by 1137 definition, is equal to JDN - 2400000.5. 1138 %End 1139 1140 double GetRataDie() const; 1141 %Docstring 1142 GetRataDie() -> double 1143 1144 Return the Rata Die number of this date. 1145 %End 1146 1147 wxDateTime FromTimezone( 1148 const TimeZone & tz, 1149 bool noDST = false 1150 ) const; 1151 %Docstring 1152 FromTimezone(tz, noDST=False) -> DateTime 1153 1154 Transform the date from the given time zone to the local one. 1155 %End 1156 1157 int IsDST( 1158 Country country = Country_Default 1159 ) const; 1160 %Docstring 1161 IsDST(country=Country_Default) -> int 1162 1163 Returns true if the DST is applied for this date in the given country. 1164 %End 1165 1166 wxDateTime & MakeFromTimezone( 1167 const TimeZone & tz, 1168 bool noDST = false 1169 ); 1170 %Docstring 1171 MakeFromTimezone(tz, noDST=False) -> DateTime 1172 1173 Same as FromTimezone() but modifies the object in place. 1174 %End 1175 1176 wxDateTime & MakeTimezone( 1177 const TimeZone & tz, 1178 bool noDST = false 1179 ); 1180 %Docstring 1181 MakeTimezone(tz, noDST=False) -> DateTime 1182 1183 Modifies the object in place to represent the date in another time 1184 zone. 1185 %End 1186 1187 wxDateTime & MakeUTC( 1188 bool noDST = false 1189 ); 1190 %Docstring 1191 MakeUTC(noDST=False) -> DateTime 1192 1193 This is the same as calling MakeTimezone() with the argument GMT0. 1194 %End 1195 1196 wxDateTime ToTimezone( 1197 const TimeZone & tz, 1198 bool noDST = false 1199 ) const; 1200 %Docstring 1201 ToTimezone(tz, noDST=False) -> DateTime 1202 1203 Transform the date to the given time zone. 1204 %End 1205 1206 wxDateTime ToUTC( 1207 bool noDST = false 1208 ) const; 1209 %Docstring 1210 ToUTC(noDST=False) -> DateTime 1211 1212 This is the same as calling ToTimezone() with the argument GMT0. 1213 %End 1214 1215 typedef unsigned short wxDateTime_t; 1216 1217 static 1218 int ConvertYearToBC( 1219 int year 1220 ); 1221 %Docstring 1222 ConvertYearToBC(year) -> int 1223 1224 Converts the year in absolute notation (i.e. a number which can be 1225 negative, positive or zero) to the year in BC/AD notation. 1226 %End 1227 1228 static 1229 void GetAmPmStrings( 1230 wxString * am /Out/, 1231 wxString * pm /Out/ 1232 ); 1233 %Docstring 1234 GetAmPmStrings() -> (am, pm) 1235 1236 Returns the translations of the strings AM and PM used for time 1237 formatting for the current locale. 1238 %End 1239 1240 static 1241 wxDateTime GetBeginDST( 1242 int year = Inv_Year, 1243 Country country = Country_Default 1244 ); 1245 %Docstring 1246 GetBeginDST(year=Inv_Year, country=Country_Default) -> DateTime 1247 1248 Get the beginning of DST for the given country in the given year 1249 (current one by default). 1250 %End 1251 1252 static 1253 wxDateTime GetEndDST( 1254 int year = Inv_Year, 1255 Country country = Country_Default 1256 ); 1257 %Docstring 1258 GetEndDST(year=Inv_Year, country=Country_Default) -> DateTime 1259 1260 Returns the end of DST for the given country in the given year 1261 (current one by default). 1262 %End 1263 1264 static 1265 Country GetCountry(); 1266 %Docstring 1267 GetCountry() -> Country 1268 1269 Returns the current default country. 1270 %End 1271 1272 static 1273 wxDateTime::Month GetCurrentMonth( 1274 Calendar cal = Gregorian 1275 ); 1276 %Docstring 1277 GetCurrentMonth(cal=Gregorian) -> DateTime.Month 1278 1279 Get the current month in given calendar (only Gregorian is currently 1280 supported). 1281 %End 1282 1283 static 1284 int GetCurrentYear( 1285 Calendar cal = Gregorian 1286 ); 1287 %Docstring 1288 GetCurrentYear(cal=Gregorian) -> int 1289 1290 Get the current year in given calendar (only Gregorian is currently 1291 supported). 1292 %End 1293 1294 static 1295 wxString GetEnglishMonthName( 1296 wxDateTime::Month month, 1297 NameFlags flags = Name_Full 1298 ); 1299 %Docstring 1300 GetEnglishMonthName(month, flags=Name_Full) -> String 1301 1302 Return the standard English name of the given month. 1303 %End 1304 1305 static 1306 wxString GetEnglishWeekDayName( 1307 wxDateTime::WeekDay weekday, 1308 NameFlags flags = Name_Full 1309 ); 1310 %Docstring 1311 GetEnglishWeekDayName(weekday, flags=Name_Full) -> String 1312 1313 Return the standard English name of the given week day. 1314 %End 1315 1316 static 1317 wxString GetMonthName( 1318 wxDateTime::Month month, 1319 NameFlags flags = Name_Full 1320 ); 1321 %Docstring 1322 GetMonthName(month, flags=Name_Full) -> String 1323 1324 Gets the full (default) or abbreviated name of the given month. 1325 %End 1326 1327 static 1328 unsigned short GetNumberOfDays( 1329 wxDateTime::Month month, 1330 int year = Inv_Year, 1331 Calendar cal = Gregorian 1332 ); 1333 %Docstring 1334 GetNumberOfDays(month, year=Inv_Year, cal=Gregorian) -> unsignedshort 1335 1336 Returns the number of days in the given month of the given year. 1337 %End 1338 1339 static 1340 time_t GetTimeNow(); 1341 %Docstring 1342 GetTimeNow() -> time_t 1343 1344 Returns the current time. 1345 %End 1346 1347 static 1348 wxString GetWeekDayName( 1349 wxDateTime::WeekDay weekday, 1350 NameFlags flags = Name_Full 1351 ); 1352 %Docstring 1353 GetWeekDayName(weekday, flags=Name_Full) -> String 1354 1355 Gets the full (default) or abbreviated name of the given week day. 1356 %End 1357 1358 static 1359 bool IsDSTApplicable( 1360 int year = Inv_Year, 1361 Country country = Country_Default 1362 ); 1363 %Docstring 1364 IsDSTApplicable(year=Inv_Year, country=Country_Default) -> bool 1365 1366 Returns true if DST was used in the given year (the current one by 1367 default) in the given country. 1368 %End 1369 1370 static 1371 bool IsLeapYear( 1372 int year = Inv_Year, 1373 Calendar cal = Gregorian 1374 ); 1375 %Docstring 1376 IsLeapYear(year=Inv_Year, cal=Gregorian) -> bool 1377 1378 Returns true if the year is a leap one in the specified calendar. 1379 %End 1380 1381 static 1382 bool IsWestEuropeanCountry( 1383 Country country = Country_Default 1384 ); 1385 %Docstring 1386 IsWestEuropeanCountry(country=Country_Default) -> bool 1387 1388 This function returns true if the specified (or default) country is 1389 one of Western European ones. 1390 %End 1391 1392 static 1393 wxDateTime Now(); 1394 %Docstring 1395 Now() -> DateTime 1396 1397 Returns the object corresponding to the current time. 1398 %End 1399 1400 static 1401 void SetCountry( 1402 Country country 1403 ); 1404 %Docstring 1405 SetCountry(country) 1406 1407 Sets the country to use by default. 1408 %End 1409 1410 static 1411 wxDateTime SetToWeekOfYear( 1412 int year, 1413 unsigned short numWeek, 1414 wxDateTime::WeekDay weekday = Mon 1415 ); 1416 %Docstring 1417 SetToWeekOfYear(year, numWeek, weekday=Mon) -> DateTime 1418 1419 Set the date to the given weekday in the week number numWeek of the 1420 given year . 1421 %End 1422 1423 static 1424 wxDateTime Today(); 1425 %Docstring 1426 Today() -> DateTime 1427 1428 Returns the object corresponding to the midnight of the current day 1429 (i.e. the same as Now(), but the time part is set to 0). 1430 %End 1431 1432 static 1433 wxDateTime UNow(); 1434 %Docstring 1435 UNow() -> DateTime 1436 1437 Returns the object corresponding to the current UTC time including the 1438 milliseconds. 1439 %End 1440 1441 static wxDateTime* FromTimeT(time_t timet) /Factory/; 1442 %Docstring 1443 FromTimeT(timet) -> DateTime 1444 1445 Construct a :class:`DateTime` from a C ``time_t`` value, the number of 1446 seconds since the epoch. 1447 %End 1448 %MethodCode 1449 PyErr_Clear(); 1450 Py_BEGIN_ALLOW_THREADS 1451 sipRes = _wxDateTime_FromTimeT(timet); 1452 Py_END_ALLOW_THREADS 1453 if (PyErr_Occurred()) sipIsErr = 1; 1454 %End 1455 %TypeCode 1456 wxDateTime* _wxDateTime_FromTimeT(time_t timet) 1457 { 1458 return new wxDateTime(timet); 1459 } 1460 %End 1461 1462 static wxDateTime* FromJDN(double jdn) /Factory/; 1463 %Docstring 1464 FromJDN(jdn) -> DateTime 1465 1466 Construct a :class:`DateTime` from a Julian Day Number. 1467 1468 By definition, the Julian Day Number, usually abbreviated as JDN, of a 1469 particular instant is the fractional number of days since 12 hours 1470 Universal Coordinated Time (Greenwich mean noon) on January 1 of the 1471 year -4712 in the Julian proleptic calendar. 1472 %End 1473 %MethodCode 1474 PyErr_Clear(); 1475 Py_BEGIN_ALLOW_THREADS 1476 sipRes = _wxDateTime_FromJDN(jdn); 1477 Py_END_ALLOW_THREADS 1478 if (PyErr_Occurred()) sipIsErr = 1; 1479 %End 1480 %TypeCode 1481 wxDateTime* _wxDateTime_FromJDN(double jdn) 1482 { 1483 return new wxDateTime(jdn); 1484 } 1485 %End 1486 1487 static wxDateTime* FromHMS(unsigned short hour, 1488 unsigned short minute=0, 1489 unsigned short second=0, 1490 unsigned short millisecond=0) /Factory/; 1491 %Docstring 1492 FromHMS(hour, minute=0, second=0, millisecond=0) -> DateTime 1493 1494 Construct a :class:`DateTime` equal to :meth:`Today` () with the time 1495 set to the supplied parameters. 1496 %End 1497 %MethodCode 1498 PyErr_Clear(); 1499 Py_BEGIN_ALLOW_THREADS 1500 sipRes = _wxDateTime_FromHMS(hour, minute, second, millisecond); 1501 Py_END_ALLOW_THREADS 1502 if (PyErr_Occurred()) sipIsErr = 1; 1503 %End 1504 %TypeCode 1505 wxDateTime* _wxDateTime_FromHMS(unsigned short hour, unsigned short minute, unsigned short second, unsigned short millisecond) 1506 { 1507 return new wxDateTime(hour, minute, second, millisecond); 1508 } 1509 %End 1510 1511 static wxDateTime* FromDMY(unsigned short day, 1512 wxDateTime::Month month, 1513 int year = Inv_Year, 1514 unsigned short hour=0, 1515 unsigned short minute=0, 1516 unsigned short second=0, 1517 unsigned short millisecond=0) /Factory/; 1518 %Docstring 1519 FromDMY(day, month, year=Inv_Year, hour=0, minute=0, second=0, millisecond=0) -> DateTime 1520 1521 Construct a :class:`DateTime` using the supplied parameters. 1522 %End 1523 %MethodCode 1524 PyErr_Clear(); 1525 Py_BEGIN_ALLOW_THREADS 1526 sipRes = _wxDateTime_FromDMY(day, month, year, hour, minute, second, millisecond); 1527 Py_END_ALLOW_THREADS 1528 if (PyErr_Occurred()) sipIsErr = 1; 1529 %End 1530 %TypeCode 1531 wxDateTime* _wxDateTime_FromDMY(unsigned short day, wxDateTime::Month month, int year, unsigned short hour, unsigned short minute, unsigned short second, unsigned short millisecond) 1532 { 1533 return new wxDateTime(day, month, year, hour, minute, second, millisecond); 1534 } 1535 %End 1536 1537 %Property(name=day, get=GetDay, set=SetDay) 1538 %Property(name=month, get=GetMonth, set=SetMonth) 1539 %Property(name=year, get=GetYear, set=SetYear) 1540 %Property(name=hour, get=GetHour, set=SetHour) 1541 %Property(name=minute, get=GetMinute, set=SetMinute) 1542 %Property(name=second, get=GetSecond, set=SetSecond) 1543 %Property(name=millisecond, get=GetMillisecond, set=SetMillisecond) 1544 %Property(name=JDN, get=GetJDN, set=SetJDN) 1545 %Property(name=DayOfYear, get=GetDayOfYear) 1546 %Property(name=JulianDayNumber, get=GetJulianDayNumber) 1547 %Property(name=LastMonthDay, get=GetLastMonthDay) 1548 %Property(name=MJD, get=GetMJD) 1549 %Property(name=ModifiedJulianDayNumber, get=GetModifiedJulianDayNumber) 1550 %Property(name=RataDie, get=GetRataDie) 1551 %Property(name=Ticks, get=GetTicks) 1552 %Property(name=WeekOfMonth, get=GetWeekOfMonth) 1553 %Property(name=WeekOfYear, get=GetWeekOfYear) 1554 bool operator<(const wxDateTime& dt) const; 1555 bool operator<=(const wxDateTime& dt) const; 1556 bool operator>(const wxDateTime& dt) const; 1557 bool operator>=(const wxDateTime& dt) const; 1558 bool operator==(const wxDateTime& dt) const; 1559 bool operator!=(const wxDateTime& dt) const; 1560 wxDateTime& operator+=(const wxTimeSpan& diff); 1561 wxDateTime operator+(const wxTimeSpan& ts) const; 1562 wxDateTime& operator-=(const wxTimeSpan& diff); 1563 wxDateTime operator-(const wxTimeSpan& ts) const; 1564 wxDateTime& operator+=(const wxDateSpan& diff); 1565 wxDateTime operator+(const wxDateSpan& ds) const; 1566 wxDateTime& operator-=(const wxDateSpan& diff); 1567 wxDateTime operator-(const wxDateSpan& ds) const; 1568 wxTimeSpan operator-(const wxDateTime& dt2) const; 1569 1570 1571 %ConvertToTypeCode 1572 // Code to test a PyObject for compatibility with wxDateTime 1573 if (!sipIsErr) { 1574 if (sipCanConvertToType(sipPy, sipType_wxDateTime, SIP_NO_CONVERTORS)) 1575 return TRUE; 1576 if (wxPyDateTime_Check(sipPy) || wxPyDate_Check(sipPy)) 1577 return TRUE; 1578 return FALSE; 1579 } 1580 1581 // Code to convert a compatible PyObject to a wxDateTime 1582 if (wxPyDateTime_Check(sipPy)) { 1583 *sipCppPtr = wxPyDateTime_ToWxDateTime(sipPy); 1584 return sipGetState(sipTransferObj); 1585 } 1586 if (wxPyDate_Check(sipPy)) { 1587 *sipCppPtr = wxPyDate_ToWxDateTime(sipPy); 1588 return sipGetState(sipTransferObj); 1589 } 1590 // if we get this far then it must already be a wxDateTime instance 1591 *sipCppPtr = reinterpret_cast<wxDateTime*>(sipConvertToType( 1592 sipPy, sipType_wxDateTime, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr)); 1593 1594 return 0; // Not a new instance 1595 %End 1596}; // end of class wxDateTime 1597 1598 1599%Extract(id=pycode_core) 1600def _DateTime___repr__(self): 1601 from six import PY2 1602 if self.IsValid(): 1603 f = self.Format() 1604 if PY2: f = f.encode('utf-8') 1605 return '<wx.DateTime: "%s">' % f 1606 else: 1607 return '<wx.DateTime: "INVALID">' 1608DateTime.__repr__ = _DateTime___repr__ 1609del _DateTime___repr__ 1610%End 1611 1612%Extract(id=pycode_core) 1613def _DateTime___str__(self): 1614 from six import PY2 1615 if self.IsValid(): 1616 f = self.Format() 1617 if PY2: f = f.encode('utf-8') 1618 return f 1619 else: 1620 return "INVALID DateTime" 1621DateTime.__str__ = _DateTime___str__ 1622del _DateTime___str__ 1623%End 1624 1625class wxDateSpan 1626{ 1627 %Docstring 1628 DateSpan(years=0, months=0, weeks=0, days=0) 1629 1630 This class is a "logical time span" and is useful for implementing 1631 program logic for such things as "add one month to the date" which, in 1632 general, doesn't mean to add 60*60*24*31 seconds to it, but to take 1633 the same date the next month (to understand that this is indeed 1634 different consider adding one month to Feb, 15 we want to get Mar, 1635 15, of course). 1636 %End 1637 %TypeHeaderCode 1638 #include <wx/datetime.h> 1639 %End 1640 1641public: 1642 wxDateSpan( 1643 int years = 0, 1644 int months = 0, 1645 int weeks = 0, 1646 int days = 0 1647 ); 1648 1649 wxDateSpan & Add( 1650 const wxDateSpan & other 1651 ); 1652 %Docstring 1653 Add(other) -> DateSpan 1654 1655 Adds the given wxDateSpan to this wxDateSpan and returns a reference 1656 to itself. 1657 %End 1658 1659 int GetDays() const; 1660 %Docstring 1661 GetDays() -> int 1662 1663 Returns the number of days (not counting the weeks component) in this 1664 date span. 1665 %End 1666 1667 int GetMonths() const; 1668 %Docstring 1669 GetMonths() -> int 1670 1671 Returns the number of the months (not counting the years) in this date 1672 span. 1673 %End 1674 1675 int GetTotalMonths() const; 1676 %Docstring 1677 GetTotalMonths() -> int 1678 1679 Returns the combined number of months in this date span, counting both 1680 years and months. 1681 %End 1682 1683 int GetTotalDays() const; 1684 %Docstring 1685 GetTotalDays() -> int 1686 1687 Returns the combined number of days in this date span, counting both 1688 weeks and days. 1689 %End 1690 1691 int GetWeeks() const; 1692 %Docstring 1693 GetWeeks() -> int 1694 1695 Returns the number of weeks in this date span. 1696 %End 1697 1698 int GetYears() const; 1699 %Docstring 1700 GetYears() -> int 1701 1702 Returns the number of years in this date span. 1703 %End 1704 1705 wxDateSpan & Multiply( 1706 int factor 1707 ); 1708 %Docstring 1709 Multiply(factor) -> DateSpan 1710 1711 Multiplies this date span by the specified factor. 1712 %End 1713 1714 wxDateSpan & Neg(); 1715 %Docstring 1716 Neg() -> DateSpan 1717 1718 Changes the sign of this date span. 1719 %End 1720 1721 wxDateSpan Negate() const; 1722 %Docstring 1723 Negate() -> DateSpan 1724 1725 Returns a date span with the opposite sign. 1726 %End 1727 1728 wxDateSpan & SetDays( 1729 int n 1730 ); 1731 %Docstring 1732 SetDays(n) -> DateSpan 1733 1734 Sets the number of days (without modifying any other components) in 1735 this date span. 1736 %End 1737 1738 wxDateSpan & SetMonths( 1739 int n 1740 ); 1741 %Docstring 1742 SetMonths(n) -> DateSpan 1743 1744 Sets the number of months (without modifying any other components) in 1745 this date span. 1746 %End 1747 1748 wxDateSpan & SetWeeks( 1749 int n 1750 ); 1751 %Docstring 1752 SetWeeks(n) -> DateSpan 1753 1754 Sets the number of weeks (without modifying any other components) in 1755 this date span. 1756 %End 1757 1758 wxDateSpan & SetYears( 1759 int n 1760 ); 1761 %Docstring 1762 SetYears(n) -> DateSpan 1763 1764 Sets the number of years (without modifying any other components) in 1765 this date span. 1766 %End 1767 1768 wxDateSpan & Subtract( 1769 const wxDateSpan & other 1770 ); 1771 %Docstring 1772 Subtract(other) -> DateSpan 1773 1774 Subtracts the given wxDateSpan to this wxDateSpan and returns a 1775 reference to itself. 1776 %End 1777 1778 static 1779 wxDateSpan Day(); 1780 %Docstring 1781 Day() -> DateSpan 1782 1783 Returns a date span object corresponding to one day. 1784 %End 1785 1786 static 1787 wxDateSpan Days( 1788 int days 1789 ); 1790 %Docstring 1791 Days(days) -> DateSpan 1792 1793 Returns a date span object corresponding to the given number of days. 1794 %End 1795 1796 static 1797 wxDateSpan Month(); 1798 %Docstring 1799 Month() -> DateSpan 1800 1801 Returns a date span object corresponding to one month. 1802 %End 1803 1804 static 1805 wxDateSpan Months( 1806 int mon 1807 ); 1808 %Docstring 1809 Months(mon) -> DateSpan 1810 1811 Returns a date span object corresponding to the given number of 1812 months. 1813 %End 1814 1815 static 1816 wxDateSpan Week(); 1817 %Docstring 1818 Week() -> DateSpan 1819 1820 Returns a date span object corresponding to one week. 1821 %End 1822 1823 static 1824 wxDateSpan Weeks( 1825 int weeks 1826 ); 1827 %Docstring 1828 Weeks(weeks) -> DateSpan 1829 1830 Returns a date span object corresponding to the given number of weeks. 1831 %End 1832 1833 static 1834 wxDateSpan Year(); 1835 %Docstring 1836 Year() -> DateSpan 1837 1838 Returns a date span object corresponding to one year. 1839 %End 1840 1841 static 1842 wxDateSpan Years( 1843 int years 1844 ); 1845 %Docstring 1846 Years(years) -> DateSpan 1847 1848 Returns a date span object corresponding to the given number of years. 1849 %End 1850 1851 wxDateSpan& operator+=(const wxDateSpan& other); 1852 wxDateSpan operator+(const wxDateSpan& ds) const; 1853 wxDateSpan& operator-=(const wxDateSpan& other); 1854 wxDateSpan operator-(const wxDateSpan& ds) const; 1855 wxDateSpan& operator-(); 1856 wxDateSpan& operator*=(int factor); 1857 wxDateSpan operator*(int n) const; 1858 bool operator==(const wxDateSpan& ds) const; 1859 bool operator!=(const wxDateSpan& ds) const; 1860 1861 1862}; // end of class wxDateSpan 1863 1864 1865class wxTimeSpan 1866{ 1867 %Docstring 1868 TimeSpan() 1869 TimeSpan(hours, min=0, sec=0, msec=0) 1870 1871 wxTimeSpan class represents a time interval. 1872 %End 1873 %TypeHeaderCode 1874 #include <wx/datetime.h> 1875 %End 1876 1877public: 1878 wxTimeSpan(); 1879 1880 wxTimeSpan( 1881 long hours, 1882 long min = 0, 1883 wxLongLong sec = 0, 1884 wxLongLong msec = 0 1885 ); 1886 1887 wxTimeSpan Abs() const; 1888 %Docstring 1889 Abs() -> TimeSpan 1890 1891 Returns the absolute value of the timespan: does not modify the 1892 object. 1893 %End 1894 1895 wxTimeSpan & Add( 1896 const wxTimeSpan & diff 1897 ); 1898 %Docstring 1899 Add(diff) -> TimeSpan 1900 1901 Adds the given wxTimeSpan to this wxTimeSpan and returns a reference 1902 to itself. 1903 %End 1904 1905 wxString Format( 1906 const wxString & format = wxDefaultTimeSpanFormat 1907 ) const; 1908 %Docstring 1909 Format(format=DefaultTimeSpanFormat) -> String 1910 1911 Returns the string containing the formatted representation of the time 1912 span. 1913 %End 1914 1915 int GetDays() const; 1916 %Docstring 1917 GetDays() -> int 1918 1919 Returns the difference in number of days. 1920 %End 1921 1922 int GetHours() const; 1923 %Docstring 1924 GetHours() -> int 1925 1926 Returns the difference in number of hours. 1927 %End 1928 1929 wxLongLong GetMilliseconds() const; 1930 %Docstring 1931 GetMilliseconds() -> LongLong 1932 1933 Returns the difference in number of milliseconds. 1934 %End 1935 1936 int GetMinutes() const; 1937 %Docstring 1938 GetMinutes() -> int 1939 1940 Returns the difference in number of minutes. 1941 %End 1942 1943 wxLongLong GetSeconds() const; 1944 %Docstring 1945 GetSeconds() -> LongLong 1946 1947 Returns the difference in number of seconds. 1948 %End 1949 1950 wxLongLong GetValue() const; 1951 %Docstring 1952 GetValue() -> LongLong 1953 1954 Returns the internal representation of timespan. 1955 %End 1956 1957 int GetWeeks() const; 1958 %Docstring 1959 GetWeeks() -> int 1960 1961 Returns the difference in number of weeks. 1962 %End 1963 1964 bool IsEqualTo( 1965 const wxTimeSpan & ts 1966 ) const; 1967 %Docstring 1968 IsEqualTo(ts) -> bool 1969 1970 Returns true if two timespans are equal. 1971 %End 1972 1973 bool IsLongerThan( 1974 const wxTimeSpan & ts 1975 ) const; 1976 %Docstring 1977 IsLongerThan(ts) -> bool 1978 1979 Compares two timespans: works with the absolute values, i.e. -2 hours 1980 is longer than 1 hour. 1981 %End 1982 1983 bool IsNegative() const; 1984 %Docstring 1985 IsNegative() -> bool 1986 1987 Returns true if the timespan is negative. 1988 %End 1989 1990 bool IsNull() const; 1991 %Docstring 1992 IsNull() -> bool 1993 1994 Returns true if the timespan is empty. 1995 %End 1996 1997 bool IsPositive() const; 1998 %Docstring 1999 IsPositive() -> bool 2000 2001 Returns true if the timespan is positive. 2002 %End 2003 2004 bool IsShorterThan( 2005 const wxTimeSpan & ts 2006 ) const; 2007 %Docstring 2008 IsShorterThan(ts) -> bool 2009 2010 Compares two timespans: works with the absolute values, i.e. 1 hour is 2011 shorter than -2 hours. 2012 %End 2013 2014 wxTimeSpan & Multiply( 2015 int n 2016 ); 2017 %Docstring 2018 Multiply(n) -> TimeSpan 2019 2020 Multiplies this time span by n. 2021 %End 2022 2023 wxTimeSpan & Neg(); 2024 %Docstring 2025 Neg() -> TimeSpan 2026 2027 Negate the value of the timespan. 2028 %End 2029 2030 wxTimeSpan Negate() const; 2031 %Docstring 2032 Negate() -> TimeSpan 2033 2034 Returns timespan with inverted sign. 2035 %End 2036 2037 wxTimeSpan & Subtract( 2038 const wxTimeSpan & diff 2039 ); 2040 %Docstring 2041 Subtract(diff) -> TimeSpan 2042 2043 Subtracts the given wxTimeSpan to this wxTimeSpan and returns a 2044 reference to itself. 2045 %End 2046 2047 static 2048 wxTimeSpan Day(); 2049 %Docstring 2050 Day() -> TimeSpan 2051 2052 Returns the timespan for one day. 2053 %End 2054 2055 static 2056 wxTimeSpan Days( 2057 long days 2058 ); 2059 %Docstring 2060 Days(days) -> TimeSpan 2061 2062 Returns the timespan for the given number of days. 2063 %End 2064 2065 static 2066 wxTimeSpan Hour(); 2067 %Docstring 2068 Hour() -> TimeSpan 2069 2070 Returns the timespan for one hour. 2071 %End 2072 2073 static 2074 wxTimeSpan Hours( 2075 long hours 2076 ); 2077 %Docstring 2078 Hours(hours) -> TimeSpan 2079 2080 Returns the timespan for the given number of hours. 2081 %End 2082 2083 static 2084 wxTimeSpan Millisecond(); 2085 %Docstring 2086 Millisecond() -> TimeSpan 2087 2088 Returns the timespan for one millisecond. 2089 %End 2090 2091 static 2092 wxTimeSpan Milliseconds( 2093 wxLongLong ms 2094 ); 2095 %Docstring 2096 Milliseconds(ms) -> TimeSpan 2097 2098 Returns the timespan for the given number of milliseconds. 2099 %End 2100 2101 static 2102 wxTimeSpan Minute(); 2103 %Docstring 2104 Minute() -> TimeSpan 2105 2106 Returns the timespan for one minute. 2107 %End 2108 2109 static 2110 wxTimeSpan Minutes( 2111 long min 2112 ); 2113 %Docstring 2114 Minutes(min) -> TimeSpan 2115 2116 Returns the timespan for the given number of minutes. 2117 %End 2118 2119 static 2120 wxTimeSpan Second(); 2121 %Docstring 2122 Second() -> TimeSpan 2123 2124 Returns the timespan for one second. 2125 %End 2126 2127 static 2128 wxTimeSpan Seconds( 2129 wxLongLong sec 2130 ); 2131 %Docstring 2132 Seconds(sec) -> TimeSpan 2133 2134 Returns the timespan for the given number of seconds. 2135 %End 2136 2137 static 2138 wxTimeSpan Week(); 2139 %Docstring 2140 Week() -> TimeSpan 2141 2142 Returns the timespan for one week. 2143 %End 2144 2145 static 2146 wxTimeSpan Weeks( 2147 long weeks 2148 ); 2149 %Docstring 2150 Weeks(weeks) -> TimeSpan 2151 2152 Returns the timespan for the given number of weeks. 2153 %End 2154 2155 wxTimeSpan& operator+=(const wxTimeSpan& diff); 2156 wxTimeSpan operator+(const wxTimeSpan& ts) const; 2157 wxTimeSpan& operator-=(const wxTimeSpan& diff); 2158 wxTimeSpan operator-(const wxTimeSpan& ts); 2159 wxTimeSpan& operator*=(int n); 2160 wxTimeSpan operator*(int n) const; 2161 wxTimeSpan& operator-(); 2162 bool operator<(const wxTimeSpan &ts) const; 2163 bool operator<=(const wxTimeSpan &ts) const; 2164 bool operator>(const wxTimeSpan &ts) const; 2165 bool operator>=(const wxTimeSpan &ts) const; 2166 bool operator==(const wxTimeSpan &ts) const; 2167 bool operator!=(const wxTimeSpan &ts) const; 2168 2169 2170}; // end of class wxTimeSpan 2171 2172 2173const wxDateTime wxDefaultDateTime; 2174 2175%Extract(id=pycode_core) 2176InvalidDateTime = DefaultDateTime 2177 2178%End 2179 2180%Extract(id=pycode_core) 2181@wx.deprecatedMsg("Use :meth:`DateTime.FromTimeT` instead.") 2182def DateTimeFromTimeT(timet): 2183 """ 2184 Compatibility wrapper for :meth:`DateTime.FromTimeT` 2185 """ 2186 return DateTime.FromTimeT(timet) 2187 2188%End 2189 2190%Extract(id=pycode_core) 2191@wx.deprecatedMsg("Use :meth:`DateTime.FromJDN` instead.") 2192def DateTimeFromJDN(jdn): 2193 """ 2194 Compatibility wrapper for :meth:`DateTime.FromJDN` 2195 """ 2196 return DateTime.FromJDN(jdn) 2197 2198%End 2199 2200%Extract(id=pycode_core) 2201@wx.deprecatedMsg("Use :meth:`DateTime.FromHMS` instead.") 2202def DateTimeFromHMS(hour, minute=0, second=0, millisecond=0): 2203 """ 2204 Compatibility wrapper for :meth:`DateTime.FromHMS` 2205 """ 2206 return DateTime.FromHMS(hour, minute, second, millisecond) 2207 2208%End 2209 2210%Extract(id=pycode_core) 2211@wx.deprecatedMsg("Use :meth:`DateTime.FromDMY` instead.") 2212def DateTimeFromDMY(day, month, year=DateTime.Inv_Year, hour=0, minute=0, second=0, millisecond=0): 2213 """ 2214 Compatibility wrapper for :meth:`DateTime.FromDMY` 2215 """ 2216 return DateTime.FromDMY(day, month, year, hour, minute, second, millisecond) 2217 2218%End 2219 2220%Extract(id=pycode_core) 2221def pydate2wxdate(date): 2222 """ 2223 Convert a Python date or datetime to a :class:`DateTime` object 2224 """ 2225 import datetime 2226 assert isinstance(date, (datetime.datetime, datetime.date)) 2227 return DateTime(date) # the built-in typemap will convert it for us 2228 2229%End 2230 2231%Extract(id=pycode_core) 2232def wxdate2pydate(date): 2233 """ 2234 Convert a :class:`DateTime` object to a Python datetime. 2235 """ 2236 import datetime 2237 assert isinstance(date, DateTime) 2238 if date.IsValid(): 2239 return datetime.datetime(date.year, date.month+1, date.day, 2240 date.hour, date.minute, date.second, date.millisecond*1000) 2241 else: 2242 return None 2243 2244%End 2245 2246 2247//--------------------------------------------------------------------------- 2248 2249