/usr/include/kcalendarsystem.h is in kdelibs5-dev 4:4.8.4-4+deb7u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 | /*
Copyright (c) 2002 Carlos Moro <cfmoro@correo.uniovi.es>
Copyright (c) 2002-2003 Hans Petter Bieker <bieker@kde.org>
Copyright 2007, 2009, 2010 John Layt <john@layt.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KCALENDARSYSTEM_H
#define KCALENDARSYSTEM_H
#include <kdecore_export.h>
#include "klocale.h" // needed for enums
#include "kglobal.h"
#include <QtCore/QStringList>
#include <QtCore/QDate>
class KCalendarSystemPrivate;
class KCalendarEra;
/**
* KCalendarSystem abstract base class, provides support for local Calendar Systems in KDE
*
* Derived classes must be created through the create() static method
*/
class KDECORE_EXPORT KCalendarSystem
{
public:
/**
* Format for returned year number / month number / day number as string.
*/
enum StringFormat {
ShortFormat, /**< Short string format, e.g. 2000 = "00" or 6 = "6" */
LongFormat /**< Long string format, e.g. 2000 = "2000" or 6 = "06" */
};
/**
* Format for returned month / day name.
*/
enum MonthNameFormat {
ShortName, /**< Short name format, e.g. "Dec" */
LongName, /**< Long name format, e.g. "December" */
ShortNamePossessive, /**< Short name possessive format, e.g. "of Dec" */
LongNamePossessive, /**< Long name possessive format, e.g. "of December" */
NarrowName /**< Narrow name format, e.g. "D". @since 4.7 */
};
/**
* Format for returned month / day name.
*/
enum WeekDayNameFormat {
ShortDayName, /**< Short name format, e.g. "Fri" */
LongDayName, /**< Long name format, e.g. "Friday" */
NarrowDayName /**< Narrow name format, e.g. "F". @since 4.7 */
};
//KDE5 remove
/**
* @deprecated use create(KLocale::CalendarSystem, KLocale) instead
*
* Creates specific calendar type
*
* @param calType string identification of the specific calendar type
* to be constructed
* @param locale locale to use for translations. The global locale is used if null.
* @return a KCalendarSystem object
*/
KDE_DEPRECATED static KCalendarSystem *create(const QString & calType = QLatin1String("gregorian"),
const KLocale * locale = 0);
//KDE5 remove
/**
* @deprecated use create(KLocale::CalendarSystem, KSharedConfig, KLocale) instead
*
* @since 4.5
*
* Creates specific calendar type
*
* @param calType string identification of the specific calendar type to be constructed
* @param config a configuration file with a 'KCalendarSystem %calendarType' group detailing
* locale-related preferences (such as era options). The global config is used
if null.
* @param locale locale to use for translations. The global locale is used if null.
* @return a KCalendarSystem object
*/
KDE_DEPRECATED static KCalendarSystem *create(const QString & calType, KSharedConfig::Ptr config,
const KLocale * locale = 0);
//KDE5 add default value to calendarSystem
/**
* @since 4.6
*
* Creates a KCalendarSystem object for the required Calendar System
*
* @param calendarSystem the Calendar System to create, defaults to QDate compatible
* @param locale locale to use for translations. The global locale is used if null.
* @return a KCalendarSystem object
*/
static KCalendarSystem *create(KLocale::CalendarSystem calendarSystem,
const KLocale *locale = 0);
/**
* @since 4.6
*
* Creates a KCalendarSystem object for the required Calendar System
*
* @param calendarSystem the Calendar System to create
* @param config a configuration file with a 'KCalendarSystem %calendarType' group detailing
* locale-related preferences (such as era options). The global config is used
if null.
* @param locale locale to use for translations. The global locale is used if null.
* @return a KCalendarSystem object
*/
static KCalendarSystem *create(KLocale::CalendarSystem calendarSystem, KSharedConfig::Ptr config,
const KLocale *locale = 0);
//KDE5 remove
/**
* @deprecated use calendarSystemsList() instead
*
* Gets a list of names of supported calendar systems.
*
* @return list of names
*/
KDE_DEPRECATED static QStringList calendarSystems();
/**
* @since 4.6
*
* Returns the list of currently supported Calendar Systems
*
* @return list of Calendar Systems
*/
static QList<KLocale::CalendarSystem> calendarSystemsList();
//KDE5 remove
/**
* @deprecated use calendarLabel( KLocale::CalendarSystem ) instead
*
* Returns a typographically correct and translated label to display for
* the calendar system type. Use with calendarSystems() to neatly
* format labels to display on combo widget of available calendar systems.
*
* @param calendarType the specific calendar type to return the label for
*
* @return label for calendar
*/
KDE_DEPRECATED static QString calendarLabel(const QString &calendarType);
/**
* @since 4.6
*
* Returns a localized label to display for the required Calendar System type.
*
* Use with calendarSystemsList() to populate selection lists of available
* calendar systems.
*
* @param calendarSystem the specific calendar type to return the label for
* @param locale the locale to use for the label, defaults to global
* @return label for calendar
*/
static QString calendarLabel(KLocale::CalendarSystem calendarSystem, const KLocale *locale = KGlobal::locale());
//KDE5 Remove
/**
* @deprecated use calendarSystem(const QString &calendarType) instead
* @since 4.6
*
* Returns the Calendar System enum value for a given Calendar Type,
* e.g. KLocale::QDateCalendar for "gregorian"
*
* @param calendarType the calendar type to convert
* @return calendar system for calendar type
*/
KDE_DEPRECATED static KLocale::CalendarSystem calendarSystemForCalendarType(const QString &calendarType);
//KDE5 Remove
/**
* @since 4.7
*
* Returns the Calendar System enum value for a given Calendar Type,
* e.g. KLocale::QDateCalendar for "gregorian"
*
* @param calendarType the calendar type to convert
* @return calendar system for calendar type
*/
static KLocale::CalendarSystem calendarSystem(const QString &calendarType);
//KDE5 remove
/**
* @since 4.7
*
* Returns the deprecated Calendar Type for a given Calendar System enum value,
* e.g. "gregorian" for KLocale::QDateCalendar
*
* @param calendarSystem the calendar system to convert
* @return calendar type for calendar system
*/
static QString calendarType(KLocale::CalendarSystem calendarSystem);
/**
* Constructor of abstract calendar class. This will be called by derived classes.
*
* @param locale locale to use for translations. The global locale is used if null.
*/
explicit KCalendarSystem(const KLocale *locale = 0);
/**
* Constructor of abstract calendar class. This will be called by derived classes.
*
* @param config a configuration file with a 'KCalendarSystem %calendarName' group detailing
* locale-related preferences (such as era options). The global config is used
if null.
* @param locale locale to use for translations. The global locale is used if null.
*/
explicit KCalendarSystem(const KSharedConfig::Ptr config, const KLocale *locale = 0);
/**
* Destructor.
*/
virtual ~KCalendarSystem();
/**
* @deprecated use calendarSystem() instead
*
* Returns the calendar system type.
*
* @return type of calendar system
*/
KDE_DEPRECATED virtual QString calendarType() const = 0;
//KDE5 make virtual?
/**
* @since 4.6
*
* Returns the Calendar System type of the KCalendarSystem object
*
* @return type of calendar system
*/
KLocale::CalendarSystem calendarSystem() const;
//KDE5 make virtual?
/**
* @since 4.6
*
* Returns a localized label to display for the current Calendar System type.
*
* @return localized label for this Calendar System
*/
QString calendarLabel() const;
/**
* Returns a QDate holding the epoch of the calendar system. Usually YMD
* of 1/1/1, access the returned QDates method toJulianDay() if you
* require the actual Julian day number. Note: a particular calendar
* system implementation may not include the epoch in its supported range,
* or the calendar system may be proleptic in which case it supports dates
* before the epoch.
*
* @see KCalendarSystem::earliestValidDate
* @see KCalendarSystem::latestValidDate
* @see KCalendarSystem::isProleptic
* @see KCalendarSystem::isValid
*
* @return epoch of calendar system
*/
virtual QDate epoch() const;
/**
* Returns the earliest date valid in this calendar system implementation.
*
* If the calendar system is proleptic then this may be before epoch.
*
* @see KCalendarSystem::epoch
* @see KCalendarSystem::latestValidDate
*
* @return date the earliest valid date
*/
virtual QDate earliestValidDate() const;
/**
* Returns the latest date valid in this calendar system implementation.
*
* @see KCalendarSystem::epoch
* @see KCalendarSystem::earliestValidDate
*
* @return date the latest valid date
*/
virtual QDate latestValidDate() const;
/**
* Returns whether a given date is valid in this calendar system.
*
* @param year the year portion of the date to check
* @param month the month portion of the date to check
* @param day the day portion of the date to check
* @return @c true if the date is valid, @c false otherwise
*/
virtual bool isValid(int year, int month, int day) const = 0;
//KDE5 make virtual?
/**
* @since 4.4
*
* Returns whether a given date is valid in this calendar system.
*
* @param year the year portion of the date to check
* @param dayOfYear the day of year portion of the date to check
* @return @c true if the date is valid, @c false otherwise
*/
bool isValid(int year, int dayOfYear) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Returns whether a given date is valid in this calendar system.
*
* @param eraName the Era Name portion of the date to check
* @param yearInEra the Year In Era portion of the date to check
* @param month the Month portion of the date to check
* @param day the Day portion of the date to check
* @return @c true if the date is valid, @c false otherwise
*/
bool isValid(const QString &eraName, int yearInEra, int month, int day) const;
//KDE5 make virtual?
/**
* @since 4.4
*
* Returns whether a given date is valid in this calendar system.
*
* @param year the year portion of the date to check
* @param isoWeekNumber the ISO week portion of the date to check
* @param dayOfIsoWeek the day of week portion of the date to check
* @return @c true if the date is valid, @c false otherwise
*/
bool isValidIsoWeekDate(int year, int isoWeekNumber, int dayOfIsoWeek) const;
/**
* Returns whether a given date is valid in this calendar system.
*
* @param date the date to check
* @return @c true if the date is valid, @c false otherwise
*/
virtual bool isValid(const QDate &date) const;
/**
* Changes the date's year, month and day. The range of the year, month
* and day depends on which calendar is being used. All years entered
* are treated literally, i.e. no Y2K translation is applied to years
* entered in the range 00 to 99. Replaces setYMD.
*
* @param date date to change
* @param year year
* @param month month number
* @param day day of month
* @return @c true if the date is valid, @c false otherwise
*/
virtual bool setDate(QDate &date, int year, int month, int day) const;
//KDE5 make virtual?
/**
* @since 4.4
*
* Set a date using the year number and day of year number only.
*
* @param date date to change
* @param year year
* @param dayOfYear day of year
* @return @c true if the date is valid, @c false otherwise
*/
bool setDate(QDate &date, int year, int dayOfYear) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Set a date using the era, year in era number, month and day
*
* @param date date to change
* @param eraName Era string
* @param yearInEra Year In Era number
* @param month Month number
* @param day Day Of Month number
* @return @c true if the date is valid, @c false otherwise
*/
bool setDate(QDate &date, QString eraName, int yearInEra, int month, int day) const;
//KDE5 make virtual?
/**
* @since 4.4
*
* Set a date using the year number, ISO week number and day of week number.
*
* @param date date to change
* @param year year
* @param isoWeekNumber ISO week of year
* @param dayOfIsoWeek day of week Mon..Sun (1..7)
* @return @c true if the date is valid, @c false otherwise
*/
bool setDateIsoWeek(QDate &date, int year, int isoWeekNumber, int dayOfIsoWeek) const;
/**
* @deprecated Use setDate() instead
*
* Some implementations reject year range 00 to 99, but extended date
* ranges now require these to be accepted. Equivalent in QDate is
* obsoleted.
*
* Changes the date's year, month and day. The range of the year, month
* and day depends on which calendar is being used.
*
* @param date Date to change
* @param y Year
* @param m Month number
* @param d Day of month
* @return true if the date is valid; otherwise returns false.
*/
KDE_DEPRECATED virtual bool setYMD(QDate &date, int y, int m, int d) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Returns the year, month and day portion of a given date in the current calendar system
*
* @param date date to get year, month and day for
* @param year year number returned in this variable
* @param month month number returned in this variable
* @param day day of month returned in this variable
*/
void getDate(const QDate date, int *year, int *month, int *day) const;
/**
* Returns the year portion of a given date in the current calendar system
*
* @param date date to return year for
* @return year, 0 if input date is invalid
*/
virtual int year(const QDate &date) const;
/**
* Returns the month portion of a given date in the current calendar system
*
* @param date date to return month for
* @return month of year, 0 if input date is invalid
*/
virtual int month(const QDate &date) const;
/**
* Returns the day portion of a given date in the current calendar system
*
* @param date date to return day for
* @return day of the month, 0 if input date is invalid
*/
virtual int day(const QDate &date) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Returns the Era Name portion of a given date in the current calendar system,
* for example "AD" or "Anno Domini" for the Gregorian calendar and Christian Era.
*
* @param date date to return Era Name for
* @param format format to return, either short or long
* @return era name, empty string if input date is invalid
*/
QString eraName(const QDate &date, StringFormat format = ShortFormat) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Returns the Era Year portion of a given date in the current
* calendar system, for example "2000 AD" or "Heisei 22".
*
* @param date date to return Era Year for
* @param format format to return, either short or long
* @return era name, empty string if input date is invalid
*/
QString eraYear(const QDate &date, StringFormat format = ShortFormat) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Returns the Year In Era portion of a given date in the current calendar
* system, for example 1 for "1 BC".
*
* @param date date to return Year In Era for
* @return Year In Era, -1 if input date is invalid
*/
int yearInEra(const QDate &date) const;
/**
* Returns a QDate containing a date @p nyears years later.
*
* @param date The old date
* @param nyears The number of years to add
* @return The new date, null date if any errors
*/
virtual QDate addYears(const QDate &date, int nyears) const;
/**
* Returns a QDate containing a date @p nmonths months later.
*
* @param date The old date
* @param nmonths number of months to add
* @return The new date, null date if any errors
*/
virtual QDate addMonths(const QDate &date, int nmonths) const;
/**
* Returns a QDate containing a date @p ndays days later.
*
* @param date The old date
* @param ndays number of days to add
* @return The new date, null date if any errors
*/
virtual QDate addDays(const QDate &date, int ndays) const;
//KDE5 make virtual?
/**
* Returns the difference between two dates in years, months and days.
* The difference is always caculated from the earlier date to the later
* date in year, month and day order, with the @p direction parameter
* indicating which direction the difference is applied from the @p toDate.
*
* For example, the difference between 2010-06-10 and 2012-09-5 is 2 years,
* 2 months and 26 days. Note that the difference between two last days of
* the month is always 1 month, e.g. 2010-01-31 to 2010-02-28 is 1 month
* not 28 days.
*
* @param fromDate The date to start from
* @param toDate The date to end at
* @param yearsDiff Returns number of years difference
* @param monthsDiff Returns number of months difference
* @param daysDiff Returns number of days difference
* @param direction Returns direction of difference, 1 if fromDate <= toDate, -1 otherwise
*/
void dateDifference(const QDate &fromDate, const QDate &toDate,
int *yearsDiff, int *monthsDiff, int *daysDiff, int *direction) const;
//KDE5 make virtual?
/**
* Returns the difference between two dates in completed calendar years.
* The returned value will be negative if @p fromDate > @p toDate.
*
* For example, the difference between 2010-06-10 and 2012-09-5 is 2 years.
*
* @param fromDate The date to start from
* @param toDate The date to end at
* @return The number of years difference
*/
int yearsDifference(const QDate &fromDate, const QDate &toDate) const;
//KDE5 make virtual?
/**
* Returns the difference between two dates in completed calendar months
* The returned value will be negative if @p fromDate > @p toDate.
*
* For example, the difference between 2010-06-10 and 2012-09-5 is 26 months.
* Note that the difference between two last days of the month is always 1
* month, e.g. 2010-01-31 to 2010-02-28 is 1 month not 28 days.
*
* @param fromDate The date to start from
* @param toDate The date to end at
* @return The number of months difference
*/
int monthsDifference(const QDate &fromDate, const QDate &toDate) const;
//KDE5 make virtual?
/**
* Returns the difference between two dates in days
* The returned value will be negative if @p fromDate > @p toDate.
*
* @param fromDate The date to start from
* @param toDate The date to end at
* @return The number of days difference
*/
int daysDifference(const QDate &fromDate, const QDate &toDate) const;
/**
* Returns number of months in the given year
*
* @param date the date to obtain year from
* @return number of months in the year, -1 if input date invalid
*/
virtual int monthsInYear(const QDate &date) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Returns number of months in the given year
*
* @param year the required year
* @return number of months in the year, -1 if input date invalid
*/
int monthsInYear(int year) const;
/**
* Returns the number of localized weeks in the given year.
*
* @param date the date to obtain year from
* @return number of weeks in the year, -1 if input date invalid
*/
virtual int weeksInYear(const QDate &date) const;
//KDE5 Merge with virtual weeksInYear with default
/**
* @since 4.7
*
* Returns the number of Weeks in a year using the required Week Number System.
*
* Unless you specifically want a particular Week Number System (e.g. ISO Weeks)
* you should use the localized number of weeks provided by weeksInYear().
*
* @see week()
* @see formatDate()
* @param date the date to obtain year from
* @param weekNumberSystem the week number system to use
* @return number of weeks in the year, -1 if date invalid
*/
int weeksInYear(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem) const;
/**
* Returns the number of localized weeks in the given year.
*
* @param year the year
* @return number of weeks in the year, -1 if input date invalid
*/
virtual int weeksInYear(int year) const;
//KDE5 Merge with virtual weeksInYear with default
/**
* @since 4.7
*
* Returns the number of Weeks in a year using the required Week Number System.
*
* Unless you specifically want a particular Week Number System (e.g. ISO Weeks)
* you should use the localized number of weeks provided by weeksInYear().
*
* @see week()
* @see formatDate()
* @param year the year
* @param weekNumberSystem the week number system to use
* @return number of weeks in the year, -1 if date invalid
*/
int weeksInYear(int year, KLocale::WeekNumberSystem weekNumberSystem) const;
/**
* Returns the number of days in the given year.
*
* @param date the date to obtain year from
* @return number of days in year, -1 if input date invalid
*/
virtual int daysInYear(const QDate &date) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Returns the number of days in the given year.
*
* @param year the year
* @return number of days in year, -1 if input date invalid
*/
int daysInYear(int year) const;
/**
* Returns the number of days in the given month.
*
* @param date the date to obtain month from
* @return number of days in month, -1 if input date invalid
*/
virtual int daysInMonth(const QDate &date) const;
//KDE5 make virtual?
/**
* @since 4.5
*
* Returns the number of days in the given month.
*
* @param year the year the month is in
* @param month the month
* @return number of days in month, -1 if input date invalid
*/
int daysInMonth(int year, int month) const;
/**
* Returns the number of days in the given week.
*
* @param date the date to obtain week from
* @return number of days in week, -1 if input date invalid
*/
virtual int daysInWeek(const QDate &date) const;
/**
* Returns the day number of year for the given date
*
* The days are numbered 1..daysInYear()
*
* @param date the date to obtain day from
* @return day of year number, -1 if input date not valid
*/
virtual int dayOfYear(const QDate &date) const;
/**
* Returns the weekday number for the given date
*
* The weekdays are numbered 1..7 for Monday..Sunday.
*
* This value is @em not affected by the value of weekStartDay()
*
* @param date the date to obtain day from
* @return day of week number, -1 if input date not valid
*/
virtual int dayOfWeek(const QDate &date) const;
/**
* @deprecated use week() instead
*
* Returns the ISO week number for the given date.
*
* ISO 8601 defines the first week of the year as the week containing the first Thursday.
* See http://en.wikipedia.org/wiki/ISO_8601 and http://en.wikipedia.org/wiki/ISO_week_date
*
* If the date falls in the last week of the previous year or the first week of the following
* year, then the yearNum returned will be set to the appropriate year.
*
* @param date the date to obtain week from
* @param yearNum returns the year the date belongs to
* @return ISO week number, -1 if input date invalid
*/
KDE_DEPRECATED virtual int weekNumber(const QDate &date, int *yearNum = 0) const;
//KDE5 Make virtual?
/**
* Returns the localized Week Number for the date.
*
* This may be ISO, US, or any other supported week numbering scheme. If
* you specifically require the ISO Week or any other scheme, you should use
* the week(KLocale::WeekNumberSystem) form.
*
* If the date falls in the last week of the previous year or the first
* week of the following year, then the yearNum returned will be set to the
* appropriate year.
*
* @see weeksInYear()
* @see formatDate()
* @param date the date to obtain week from
* @param yearNum returns the year the date belongs to
* @return localized week number, -1 if input date invalid
*/
int week(const QDate &date, int *yearNum = 0) const;
//KDE5 Make virtual?
/**
* Returns the Week Number for the date in the required Week Number System.
*
* Unless you want a specific Week Number System (e.g. ISO Week), you should
* use the localized Week Number form of week().
*
* If the date falls in the last week of the previous year or the first
* week of the following year, then the yearNum returned will be set to the
* appropriate year.
*
* Technically, the ISO Week Number only applies to the ISO/Gregorian Calendar
* System, but the same rules will be applied to the current Calendar System.
*
* @see weeksInYear()
* @see formatDate()
* @param date the date to obtain week from
* @param weekNumberSystem the Week Number System to use
* @param yearNum returns the year the date belongs to
* @return week number, -1 if input date invalid
*/
int week(const QDate &date, KLocale::WeekNumberSystem weekNumberSystem, int *yearNum = 0) const;
/**
* Returns whether a given year is a leap year.
*
* Input year must be checked for validity in current Calendar System prior to calling, no
* validity checking performed in this routine, behaviour is undefined in invalid case.
*
* @param year the year to check
* @return @c true if the year is a leap year, @c false otherwise
*/
virtual bool isLeapYear(int year) const = 0;
/**
* Returns whether a given date falls in a leap year.
*
* Input date must be checked for validity in current Calendar System prior to calling, no
* validity checking performed in this routine, behaviour is undefined in invalid case.
*
* @param date the date to check
* @return @c true if the date falls in a leap year, @c false otherwise
*/
virtual bool isLeapYear(const QDate &date) const;
//KDE5 Make virtual?
/**
* @since 4.6
*
* Returns a QDate containing the first day of the year
*
* @param year The year to return the date for
* @return The first day of the year
*/
QDate firstDayOfYear(int year) const;
//KDE5 Make virtual?
/**
* @since 4.6
*
* Returns a QDate containing the last day of the year
*
* @param year The year to return the date for
* @return The last day of the year
*/
QDate lastDayOfYear(int year) const;
//KDE5 Make virtual?
/**
* @since 4.6
*
* Returns a QDate containing the first day of the year
*
* @param date The year to return the date for, defaults to today
* @return The first day of the year
*/
QDate firstDayOfYear(const QDate &date = QDate::currentDate()) const;
//KDE5 Make virtual?
/**
* @since 4.6
*
* Returns a QDate containing the last day of the year
*
* @param date The year to return the date for, defaults to today
* @return The last day of the year
*/
QDate lastDayOfYear(const QDate &date = QDate::currentDate()) const;
//KDE5 Make virtual?
/**
* @since 4.6
*
* Returns a QDate containing the first day of the month
*
* @param year The year to return the date for
* @param month The month to return the date for
* @return The first day of the month
*/
QDate firstDayOfMonth(int year, int month) const;
//KDE5 Make virtual?
/**
* @since 4.6
*
* Returns a QDate containing the last day of the month
*
* @param year The year to return the date for
* @param month The month to return the date for
* @return The last day of the month
*/
QDate lastDayOfMonth(int year, int month) const;
//KDE5 Make virtual?
/**
* @since 4.6
*
* Returns a QDate containing the first day of the month
*
* @param date The month to return the date for, defaults to today
* @return The first day of the month
*/
QDate firstDayOfMonth(const QDate &date = QDate::currentDate()) const;
//KDE5 Make virtual?
/**
* @since 4.6
*
* Returns a QDate containing the last day of the month
*
* @param date The month to return the date for, defaults to today
* @return The last day of the month
*/
QDate lastDayOfMonth(const QDate &date = QDate::currentDate()) const;
/**
* Gets specific calendar type month name for a given month number
* If an invalid month is specified, QString() is returned.
*
* @param month the month number
* @param year the year the month belongs to
* @param format specifies whether the short month name or long month name should be used
* @return name of the month, empty string if any error
*/
virtual QString monthName(int month, int year, MonthNameFormat format = LongName) const = 0;
/**
* Gets specific calendar type month name for a given date
*
* @param date date to obtain month from
* @param format specifies whether the short month name or long month name should be used
* @return name of the month, empty string if any error
*/
virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const;
/**
* Gets specific calendar type week day name.
* If an invalid week day is specified, QString() is returned.
*
* @param weekDay number of day in week (Monday = 1, ..., Sunday = 7)
* @param format specifies whether the short month name or long month name should be used
* @return day name, empty string if any error
*/
virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const = 0;
/**
* Gets specific calendar type week day name.
*
* @param date the date
* @param format specifies whether the short month name or long month name should be used
* @return day name, empty string if any error
*/
virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const;
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* Converts a date into a year literal
*
* @param date date to convert
* @param format format to return, either short or long
* @return year literal of the date, empty string if any error
* @see year()
*/
KDE_DEPRECATED virtual QString yearString(const QDate &date, StringFormat format = LongFormat) const;
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* Converts a date into a month literal
*
* @param pDate The date to convert
* @param format The format to return, either short or long
* @return The month literal of the date, empty string if any error
* @see month()
*/
KDE_DEPRECATED virtual QString monthString(const QDate &pDate, StringFormat format = LongFormat) const;
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* Converts a date into a day literal
*
* @param pDate The date to convert
* @param format The format to return, either short or long
* @return The day literal of the date, empty string if any error
* @see day()
*/
KDE_DEPRECATED virtual QString dayString(const QDate &pDate, StringFormat format = LongFormat) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.5
*
* Converts a date into a Year In Era literal
*
* @param date date to return Year In Era for
* @param format format to return, either short or long
* @return Year In Era literal of the date, empty string if any error
*/
KDE_DEPRECATED QString yearInEraString(const QDate &date, StringFormat format = ShortFormat) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.4
*
* Converts a date into a day of year literal
*
* @param pDate The date to convert
* @param format The format to return, either short or long
* @return The day of year literal of the date, empty string if any error
* @see dayOfYear()
*/
KDE_DEPRECATED QString dayOfYearString(const QDate &pDate, StringFormat format = LongFormat) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.4
*
* Converts a date into a day of week literal
*
* @param pDate The date to convert
* @return The day of week literal of the date, empty string if any error
* @see dayOfWeek()
*/
KDE_DEPRECATED QString dayOfWeekString(const QDate &pDate) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.4
*
* Converts a date into a week number literal
*
* @param pDate The date to convert
* @param format The format to return, either short or long
* @return The day literal of the date, empty string if any error
* @see weekNumber()
*/
KDE_DEPRECATED QString weekNumberString(const QDate &pDate, StringFormat format = LongFormat) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.4
*
* Returns the months in year for a date as a numeric string
*
* @param pDate The date to convert
* @param format The format to return, either short or long
* @return The months in year literal of the date, empty string if any error
* @see monthsInYear()
*/
KDE_DEPRECATED QString monthsInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.4
*
* Returns the weeks in year for a date as a numeric string
*
* @param pDate The date to convert
* @param format The format to return, either short or long
* @return The weeks in year literal of the date, empty string if any error
* @see weeksInYear()
*/
KDE_DEPRECATED QString weeksInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.4
*
* Returns the days in year for a date as a numeric string
*
* @param pDate The date to convert
* @param format The format to return, either short or long
* @return The days in year literal of the date, empty string if any error
* @see daysInYear()
*/
KDE_DEPRECATED QString daysInYearString(const QDate &pDate, StringFormat format = LongFormat) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.4
*
* Returns the days in month for a date as a numeric string
*
* @param pDate The date to convert
* @param format The format to return, either short or long
* @return The days in month literal of the date, empty string if any error
* @see daysInMonth()
*/
KDE_DEPRECATED QString daysInMonthString(const QDate &pDate, StringFormat format = LongFormat) const;
//KDE5 make virtual?
/**
* @deprecated use formatDate(QDate, KLocale::DateTimeComponent, KLocale::DateTimeComponentFormat)
*
* @since 4.4
*
* Returns the days in week for a date as a numeric string
*
* @param date The date to convert
* @return The days in week literal of the date, empty string if any error
* @see daysInWeek()
*/
KDE_DEPRECATED QString daysInWeekString(const QDate &date) const;
//KDE5 make protected or remove?
/**
* @deprecated for internal use only
*
* Converts a year literal of a part of a string into a integer starting at the beginning of the string
*
* @param sNum The string to parse
* @param iLength The number of QChars used, and 0 if no valid symbols was found in the string
* @return An integer corresponding to the year
*/
virtual int yearStringToInteger(const QString &sNum, int &iLength) const;
//KDE5 make protected or remove?
/**
* @deprecated for internal use only
*
* Converts a month literal of a part of a string into a integer starting at the beginning of the string
*
* @param sNum The string to parse
* @param iLength The number of QChars used, and 0 if no valid symbols was found in the string
* @return An integer corresponding to the month
*/
virtual int monthStringToInteger(const QString &sNum, int &iLength) const;
//KDE5 make protected or remove?
/**
* @deprecated for internal use only
*
* Converts a day literal of a part of a string into a integer starting at the beginning of the string
*
* @param sNum The string to parse
* @param iLength The number of QChars used, and 0 if no valid symbols was found in the string
* @return An integer corresponding to the day
*/
virtual int dayStringToInteger(const QString &sNum, int &iLength) const;
/**
* Returns a string formatted to the current locale's conventions
* regarding dates.
*
* Uses the calendar system's internal locale set when the instance was
* created, which ensures that the correct calendar system and locale
* settings are respected, which would not occur in some cases if using
* the global locale. Defaults to global locale.
*
* @see KLocale::formatDate
*
* @param fromDate the date to be formatted
* @param toFormat category of date format to use
*
* @return The date as a string
*/
virtual QString formatDate(const QDate &fromDate, KLocale::DateFormat toFormat = KLocale::LongDate) const;
//KDE5 Make virtual
/**
* @since 4.4
*
* Returns a string formatted to the given format and localised to the
* correct language and digit set using the requested format standard.
*
* *** WITH GREAT POWER COMES GREAT RESPONSIBILITY ***
* Please use with care and only in situations where the DateFormat enum
* or locale formats or individual string methods do not provide what you
* need. You should almost always translate your format string as
* documented. Using the standard DateFormat options instead would take
* care of the translation for you.
*
* Warning: The %n element differs from the GNU/POSIX standard where it is
* defined as a newline. KDE currently uses this for short day number. It
* is recommended for compatibility purposes to use %-m instead.
*
* The toFormat parameter is a good candidate to be made translatable,
* so that translators can adapt it to their language's convention.
* There should also be a context using the "kdedt-format" keyword (for
* automatic validation of translations) and stating the format's purpose:
* \code
* QDate reportDate;
* KGlobal::locale()->calendar()->setDate(reportDate, reportYear, reportMonth, 1);
* dateFormat = i18nc("(kdedt-format) Report month and year in report header", "%B %Y"));
* dateString = KGlobal::locale()->calendar()->formatDate(reportDate, dateFormat);
* \endcode
*
* The date format string can be defined using either the KDE or POSIX standards.
* The KDE standard closely follows the POSIX standard but with some exceptions.
* Always use the KDE standard within KDE, but where interaction is required with
* external POSIX compliant systems (e.g. Gnome, glibc, etc) the POSIX standard
* should be used.
*
* Date format strings are made up of date componants and string literals.
* Date componants are prefixed by a % escape character and are made up of
* optional padding and case modifier flags, an optional width value, and a
* compulsary code for the actual date componant:
* %[Flags][Width][Componant]
* e.g. %_^5Y
* No spaces are allowed.
*
* The Flags can modify the padding character and/or case of the Date Componant.
* The Flags are optional and may be combined and/or repeated in any order,
* in which case the last Padding Flag and last Case Flag will be the
* ones used. The Flags must be immediately after the % and before any Width.
*
* The Width can modify how wide the date Componant is padded to. The Width
* is an optional interger value and must be after any Flags but before the
* Componant. If the Width is less than the minimum defined for a Componant
* then the default minimum will be used instead.
*
* By default most numeric Date Componants are right-aligned with leading 0's.
*
* By default all string name fields are capital case and unpadded.
*
* The following Flags may be specified:
* @li - (hyphen) no padding (e.g. 1 Jan and "%-j" = "1")
* @li _ (underscore) pad with spaces (e.g. 1 Jan and "%-j" = " 1")
* @li 0 (zero) pad with 0's (e.g. 1 Jan and "%0j" = "001")
* @li ^ (caret) make uppercase (e.g. 1 Jan and "%^B" = "JANUARY")
* @li # (hash) invert case (e.g. 1 Jan and "%#B" = "???")
*
* The following Date Componants can be specified:
* @li %Y the year to 4 digits (e.g. "1984" for 1984, "0584" for 584, "0084" for 84)
* @li %C the 'century' portion of the year to 2 digits (e.g. "19" for 1984, "05" for 584, "00" for 84)
* @li %y the lower 2 digits of the year to 2 digits (e.g. "84" for 1984, "05" for 2005)
* @li %EY the full local era year (e.g. "2000 AD")
* @li %EC the era name short form (e.g. "AD")
* @li %Ey the year in era to 1 digit (e.g. 1 or 2000)
* @li %m the month number to 2 digits (January="01", December="12")
* @li %n the month number to 1 digit (January="1", December="12"), see notes!
* @li %d the day number of the month to 2 digits (e.g. "01" on the first of March)
* @li %e the day number of the month to 1 digit (e.g. "1" on the first of March)
* @li %B the month name long form (e.g. "January")
* @li %b the month name short form (e.g. "Jan" for January)
* @li %h the month name short form (e.g. "Jan" for January)
* @li %A the weekday name long form (e.g. "Wednesday" for Wednesday)
* @li %a the weekday name short form (e.g. "Wed" for Wednesday)
* @li %j the day of the year number to 3 digits (e.g. "001" for 1 Jan)
* @li %V the ISO week of the year number to 2 digits (e.g. "01" for ISO Week 1)
* @li %G the year number in long form of the ISO week of the year to 4 digits (e.g. "2004" for 1 Jan 2005)
* @li %g the year number in short form of the ISO week of the year to 2 digits (e.g. "04" for 1 Jan 2005)
* @li %u the day of the week number to 1 digit (e.g. "1" for Monday)
* @li %D the US short date format (e.g. "%m/%d/%y")
* @li %F the ISO short date format (e.g. "%Y-%m-%d")
* @li %x the KDE locale short date format
* @li %% the literal "%"
* @li %t a tab character
*
* Everything else in the format string will be taken as literal text.
*
* Examples:
* "%Y-%m-%d" = "2009-01-01"
* "%Y-%-m-%_4d" = "2009-1- 1"
*
* The following format codes behave differently in the KDE and POSIX standards
* @li %e in GNU/POSIX is space padded to 2 digits, in KDE is not padded
* @li %n in GNU/POSIX is newline, in KDE is short month number
*
* The following POSIX format codes are currently not supported:
* @li %U US week number
* @li %w US day of week
* @li %W US week number
* @li %O locale's alternative numeric symbols, in KDE is not supported
*
* %0 is not supported as the returned result is always in the locale's chosen numeric symbol digit set.
*
* @see KLocale::formatDate
*
* @param fromDate the date to be formatted
* @param toFormat the date format to use
* @param formatStandard the standard the date format uses, defaults to KDE Standard
*
* @return The date as a string
*/
QString formatDate(const QDate &fromDate, const QString &toFormat,
KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
//KDE5 Make virtual
/**
* @since 4.4
*
* Returns a string formatted to the given format string and Digit Set.
* Only use this version if you need control over the Digit Set and do
* not want to use the locale Digit Set.
*
* @see formatDate
*
* @param fromDate the date to be formatted
* @param toFormat the date format to use
* @param digitSet the Digit Set to format the date in
* @param formatStandard the standard the date format uses, defaults to KDE Standard
*
* @return The date as a string
*/
QString formatDate(const QDate &fromDate, const QString &toFormat, KLocale::DigitSet digitSet,
KLocale::DateTimeFormatStandard formatStandard = KLocale::KdeFormat) const;
//KDE5 Make virtual
/**
* @since 4.6
*
* Returns a Date Component as a localized string in the requested format.
*
* For example for 2010-01-01 the KLocale::Month with en_US Locale and Gregorian calendar may return:
* KLocale::ShortNumber = "1"
* KLocale::LongNumber = "01"
* KLocale::NarrowName = "J"
* KLocale::ShortName = "Jan"
* KLocale::LongName = "January"
*
* @param date The date to format
* @param component The date component to return
* @param format The format to return the @p component in
* @param weekNumberSystem To override the default Week Number System to use
* @return The localized string form of the date component
*/
QString formatDate(const QDate &date, KLocale::DateTimeComponent component,
KLocale::DateTimeComponentFormat format = KLocale::DefaultComponentFormat,
KLocale::WeekNumberSystem weekNumberSystem = KLocale::DefaultWeekNumber) const;
/**
* Converts a localized date string to a QDate.
* The bool pointed by @p ok will be @c false if the date entered was invalid.
*
* Uses the calendar system's internal locale set when the instance was
* created, which ensures that the correct calendar system and locale
* settings are respected, which would not occur in some cases if using
* the global locale. Defaults to global locale.
*
* @see KLocale::readDate
*
* @param str the string to convert
* @param ok if non-null, will be set to @c true if the date is valid, @c false if invalid
*
* @return the string converted to a QDate
*/
virtual QDate readDate(const QString &str, bool *ok = 0) const;
/**
* Converts a localized date string to a QDate.
* This method is stricter than readDate(str,&ok): it will either accept
* a date in full format or a date in short format, depending on @p flags.
*
* Uses the calendar system's internal locale set when the instance was
* created, which ensures that the correct calendar system and locale
* settings are respected, which would not occur in some cases if using
* the global locale. Defaults to global locale.
*
* @see KLocale::readDate
*
* @param str the string to convert
* @param flags whether the date string is to be in full format or in short format
* @param ok if non-null, will be set to @c true if the date is valid, @c false if invalid
*
* @return the string converted to a QDate
*/
virtual QDate readDate(const QString &str, KLocale::ReadDateFlags flags, bool *ok = 0) const;
/**
* Converts a localized date string to a QDate, using the specified @p format.
* You will usually not want to use this method. Uses teh KDE format standard.
*
* @param dateString the string to convert
* @param dateFormat the date format to use, in KDE format standard
* @param ok if non-null, will be set to @c true if the date is valid, @c false if invalid
*
* @return the string converted to a QDate
*
* @see formatDate
* @see KLocale::readDate
*/
virtual QDate readDate(const QString &dateString, const QString &dateFormat, bool *ok = 0) const;
//KDE5 Make virtual
/**
* Converts a localized date string to a QDate, using the specified @p format.
* You will usually not want to use this method.
*
* You must supply a format and string containing at least one of the following combinations to
* create a valid date:
* @li a month and day of month
* @li a day of year
* @li a ISO week number and day of week
*
* If a year number is not supplied then the current year will be assumed.
*
* All date componants must be separated by a non-numeric character.
*
* The format is not applied strictly to the input string:
* @li extra whitespace is ignored
* @li leading 0's on numbers are ignored
* @li capitalisation of literals is ignored
*
* The allowed format componants are almost the same as the formatDate() function.
* The following date componants will be read:
* @li %Y the whole year (e.g. "1984" for 1984)
* @li %y the lower 2 digits of the year (e.g. "84" for 1984)
* @li %EY the full local era year (e.g. "2000 AD")
* @li %EC the era name short form (e.g. "AD")
* @li %Ey the year in era to 1 digit (e.g. 1 or 2000)
* @li %m the month number to two digits (January="01", December="12")
* @li %n the month number (January="1", December="12")
* @li %d the day number of the month to two digits (e.g. "01" on the first of March)
* @li %e the day number of the month (e.g. "1" on the first of March)
* @li %B the month name long form (e.g. "January")
* @li %b the month name short form (e.g. "Jan" for January)
* @li %h the month name short form (e.g. "Jan" for January)
* @li %A the weekday name long form (e.g. "Wednesday" for Wednesday)
* @li %a the weekday name short form (e.g. "Wed" for Wednesday)
* @li %j the day of the year number to three digits (e.g. "001" for 1 Jan)
* @li %V the ISO week of the year number to two digits (e.g. "01" for ISO Week 1)
* @li %u the day of the week number (e.g. "1" for Monday)
*
* The following date componants are NOT supported:
* @li %C the 'century' portion of the year (e.g. "19" for 1984, "5" for 584, "" for 84)
* @li %G the year number in long form of the ISO week of the year (e.g. "2004" for 1 Jan 2005)
* @li %g the year number in short form of the ISO week of the year (e.g. "04" for 1 Jan 2005)
* @li %D the US short date format (e.g. "%m/%d/%y")
* @li %F the ISO short date format (e.g. "%Y-%m-%d")
* @li %x the KDE locale short date format
* @li %% the literal "%"
* @li %t a tab character
*
* @param dateString the string to convert
* @param dateFormat the date format to use
* @param ok if non-null, will be set to @c true if the date is valid, @c false if invalid
* @param formatStandard the standard the date format uses
*
* @return the string converted to a QDate
*
* @see formatDate
* @see KLocale::readDate
*/
QDate readDate(const QString &dateString, const QString &dateFormat, bool *ok,
KLocale::DateTimeFormatStandard formatStandard) const;
//KDE5 Make virtual
/**
* @since 4.6
*
* Returns the Short Year Window Start Year for the current Calendar System.
*
* Use this function to get the Start Year for the Short Year Window to be
* applied when 2 digit years are entered for a Short Year input format,
* e.g. if the Short Year Window Start Year is 1930, then the input Short
* Year value of 40 is interpreted as 1940 and the input Short Year value
* of 10 is interpreted as 2010.
*
* The Short Year Window is only ever applied when reading the Short Year
* format and not the Long Year format, i.e. KLocale::ShortFormat or '%y'
* only and not KLocale::LongFormat or '%Y'.
*
* The Start Year 0 effectively means not to use a Short Year Window
*
* Each Calendar System requires a different Short Year Window as they have
* different epochs. The Gregorian Short Year Window usually pivots around
* the year 2000, whereas the Hebrew Short Year Window usually pivots around
* the year 5000.
*
* This value must always be used when evaluating user input Short Year
* strings.
*
* @see KLocale::shortYearWindowStartYear
* @see KLocale::applyShortYearWindow
* @return the short year window start year
*/
int shortYearWindowStartYear() const;
//KDE5 Make virtual
/**
* @since 4.6
*
* Returns the Year Number after applying the Year Window.
*
* If the @p inputYear is between 0 and 99, then apply the Year Window and
* return the calculated Year Number.
*
* If the @p inputYear is not between 0 and 99, then the original Year Number
* is returned.
*
* @see KLocale::setYearWindowOffset
* @see KLocale::yearWindowOffset
* @param inputYear the year number to apply the year window to
* @return the year number after applying the year window
*/
int applyShortYearWindow(int inputYear) const;
/**
* Use this to determine which day is the first day of the week.
*
* Uses the calendar system's internal locale set when the instance was
* created, which ensures that the correct calendar system and locale
* settings are respected, which would not occur in some cases if using
* the global locale. Defaults to global locale.
*
* @see KLocale::weekStartDay
*
* @return an integer (Monday = 1, ..., Sunday = 7)
*/
virtual int weekStartDay() const;
/**
* @deprecated use KLocale::weekDayOfPray() instead
*
* Returns the day of the week traditionally associated with religious
* observance for this calendar system. Note this may not be accurate
* for the users locale, e.g. Gregorian calendar used in non-Christian
* countries, in use cases where this could be an issue it is recommended
* to use KLocale::weekDayOfPray() instead.
*
* @return day number (None = 0, Monday = 1, ..., Sunday = 7)
*/
KDE_DEPRECATED virtual int weekDayOfPray() const = 0;
/**
* Returns whether the calendar is lunar based.
*
* @return @c true if the calendar is lunar based, @c false if not
*/
virtual bool isLunar() const = 0;
/**
* Returns whether the calendar is lunisolar based.
*
* @return @c true if the calendar is lunisolar based, @c false if not
*/
virtual bool isLunisolar() const = 0;
/**
* Returns whether the calendar is solar based.
*
* @return @c true if the calendar is solar based, @c false if not
*/
virtual bool isSolar() const = 0;
/**
* Returns whether the calendar system is proleptic, i.e. whether dates
* before the epoch are supported.
*
* @see KCalendarSystem::epoch
*
* @return @c true if the calendar system is proleptic, @c false if not
*/
virtual bool isProleptic() const = 0;
protected:
/**
* Internal method to convert a Julian Day number into the YMD values for
* this calendar system.
*
* All calendar system implementations MUST implement julianDayToDate and
* dateToJulianDay methods as all other methods can be expressed as
* functions of these. Does no internal validity checking.
*
* @see KCalendarSystem::dateToJulianDay
*
* @param jd Julian day number to convert to date
* @param year year number returned in this variable
* @param month month number returned in this variable
* @param day day of month returned in this variable
* @return @c true if the date is valid, @c false otherwise
*/
virtual bool julianDayToDate(int jd, int &year, int &month, int &day) const = 0;
/**
* Internal method to convert YMD values for this calendar system into a
* Julian Day number.
*
* All calendar system implementations MUST implement julianDayToDate and
* dateToJulianDay methods as all other methods can be expressed as
* functions of these. Does no internal validity checking.
*
* @see KCalendarSystem::julianDayToDate
*
* @param year year number
* @param month month number
* @param day day of month
* @param jd Julian day number returned in this variable
* @return @c true if the date is valid, @c false otherwise
*/
virtual bool dateToJulianDay(int year, int month, int day, int &jd) const = 0;
/**
* Returns the locale used for translations and formats for this
* calendar system instance. This allows a calendar system instance to be
* independent of the global translations and formats if required. All
* implementations must refer to this locale.
*
* Only for internal calendar system use; if public access is required then
* provide public methods only for those methods actually required. Any
* app that creates an instance with its own locale overriding global will
* have the original handle to the locale and can manipulate it that way if
* required, e.g. to change default date format. Only expose those methods
* that library widgets require access to internally.
*
* @see KCalendarSystem::formatDate
* @see KLocale::formatDate
* @see KCalendarSystem::weekStartDay
* @see KLocale::weekStartDay
* @see KCalendarSystem::readDate
* @see KLocale::readDate
*
* @return locale to use
*/
const KLocale *locale() const;
/**
* @deprecated for internal use only
*
* Sets the maximum number of months in a year
*
* Only for internal calendar system use
*/
KDE_DEPRECATED void setMaxMonthsInYear(int maxMonths);
/**
* @deprecated for internal use only
*
* Sets the maximum number of days in a week
*
* Only for internal calendar system use
*/
KDE_DEPRECATED void setMaxDaysInWeek(int maxDays);
/**
* @deprecated for internal use only
*
* @since 4.4
*
* Sets if Calendar System has Year 0 or not
*
* Only for internal calendar system use
*/
KDE_DEPRECATED void setHasYear0(bool hasYear0);
/**
* Constructor of abstract calendar class. This will be called by derived classes.
*
* @param dd derived private d-pointer.
* @param config a configuration file with a 'KCalendarSystem %calendarName' group detailing
* locale-related preferences (such as era options). The global config is used
if null.
* @param locale locale to use for translations. The global locale is used if null.
*/
KCalendarSystem(KCalendarSystemPrivate &dd,
const KSharedConfig::Ptr config = KSharedConfig::Ptr(),
const KLocale *locale = 0);
private:
//Required for shared d-pointer as already private, remove in KDE5
friend class KCalendarSystemCoptic;
friend class KCalendarSystemEthiopian;
friend class KCalendarSystemGregorian;
friend class KCalendarSystemHebrew;
friend class KCalendarSystemIndianNational;
friend class KCalendarSystemIslamicCivil;
friend class KCalendarSystemJalali;
friend class KCalendarSystemJapanese;
friend class KCalendarSystemJulian;
friend class KCalendarSystemMinguo;
friend class KCalendarSystemQDate;
friend class KCalendarSystemThai;
//Other friends that need access to protected/private functions
friend class KLocalizedDate;
friend class KLocalizedDatePrivate;
friend class KDateTimeParser;
friend class KDateTable;
// Era functions needed by friends, may be made public later if needed in KCM
QList<KCalendarEra> *eraList() const;
KCalendarEra era(const QDate &eraDate) const;
KCalendarEra era(const QString &eraName, int yearInEra) const;
Q_DISABLE_COPY(KCalendarSystem)
KCalendarSystemPrivate * const d_ptr; // KDE5 make protected
Q_DECLARE_PRIVATE(KCalendarSystem)
};
#endif
|