Changeset 99758 in vbox for trunk/src/VBox/Runtime/common/time
- Timestamp:
- May 11, 2023 9:37:59 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/time/time.cpp
r98103 r99758 275 275 276 276 277 /**278 * Checks if a year is a leap year or not.279 *280 * @returns true if it's a leap year.281 * @returns false if it's a common year.282 * @param i32Year The year in question.283 */284 277 RTDECL(bool) RTTimeIsLeapYear(int32_t i32Year) 285 278 { … … 289 282 290 283 291 /**292 * Explodes a time spec (UTC).293 *294 * @returns pTime.295 * @param pTime Where to store the exploded time.296 * @param pTimeSpec The time spec to exploded.297 */298 284 RTDECL(PRTTIME) RTTimeExplode(PRTTIME pTime, PCRTTIMESPEC pTimeSpec) 299 285 { … … 401 387 402 388 403 /**404 * Implodes exploded time to a time spec (UTC).405 *406 * @returns pTime on success.407 * @returns NULL if the pTime data is invalid.408 * @param pTimeSpec Where to store the imploded UTC time.409 * If pTime specifies a time which outside the range, maximum or410 * minimum values will be returned.411 * @param pTime Pointer to the exploded time to implode.412 * The fields u8Month, u8WeekDay and u8MonthDay are not used,413 * and all the other fields are expected to be within their414 * bounds. Use RTTimeNormalize() or RTTimeLocalNormalize() to415 * calculate u16YearDay and normalize the ranges of the fields.416 */417 389 RTDECL(PRTTIMESPEC) RTTimeImplode(PRTTIMESPEC pTimeSpec, PCRTTIME pTime) 418 390 { … … 679 651 680 652 681 /**682 * Normalizes the fields of a time structure.683 *684 * It is possible to calculate year-day from month/day and vice685 * versa. If you adjust any of these, make sure to zero the686 * other so you make it clear which of the fields to use. If687 * it's ambiguous, the year-day field is used (and you get688 * assertions in debug builds).689 *690 * All the time fields and the year-day or month/day fields will691 * be adjusted for overflows. (Since all fields are unsigned, there692 * is no underflows.) It is possible to exploit this for simple693 * date math, though the recommended way of doing that to implode694 * the time into a timespec and do the math on that.695 *696 * @returns pTime on success.697 * @returns NULL if the data is invalid.698 *699 * @param pTime The time structure to normalize.700 *701 * @remarks This function doesn't work with local time, only with UTC time.702 */703 653 RTDECL(PRTTIME) RTTimeNormalize(PRTTIME pTime) 704 654 { … … 719 669 720 670 721 /**722 * Normalizes the fields of a time structure, assuming local time.723 *724 * It is possible to calculate year-day from month/day and vice725 * versa. If you adjust any of these, make sure to zero the726 * other so you make it clear which of the fields to use. If727 * it's ambiguous, the year-day field is used (and you get728 * assertions in debug builds).729 *730 * All the time fields and the year-day or month/day fields will731 * be adjusted for overflows. (Since all fields are unsigned, there732 * is no underflows.) It is possible to exploit this for simple733 * date math, though the recommended way of doing that to implode734 * the time into a timespec and do the math on that.735 *736 * @returns pTime on success.737 * @returns NULL if the data is invalid.738 *739 * @param pTime The time structure to normalize.740 *741 * @remarks This function doesn't work with UTC time, only with local time.742 */743 671 RTDECL(PRTTIME) RTTimeLocalNormalize(PRTTIME pTime) 744 672 { … … 758 686 759 687 760 /**761 * Converts a time spec to a ISO date string.762 *763 * @returns psz on success.764 * @returns NULL on buffer underflow.765 * @param pTime The time. Caller should've normalized this.766 * @param psz Where to store the string.767 * @param cb The size of the buffer.768 */769 688 RTDECL(char *) RTTimeToString(PCRTTIME pTime, char *psz, size_t cb) 770 689 { … … 810 729 811 730 812 /**813 * Converts a time spec to a ISO date string, extended version.814 *815 * @returns Output string length on success (positive), VERR_BUFFER_OVERFLOW816 * (negative) or VERR_OUT_OF_RANGE (negative) on failure.817 * @param pTime The time. Caller should've normalized this.818 * @param psz Where to store the string.819 * @param cb The size of the buffer.820 * @param cFractionDigits Number of digits in the fraction. Max is 9.821 */822 731 RTDECL(ssize_t) RTTimeToStringEx(PCRTTIME pTime, char *psz, size_t cb, unsigned cFractionDigits) 823 732 { … … 878 787 879 788 880 /**881 * Converts a time spec to a ISO date string.882 *883 * @returns psz on success.884 * @returns NULL on buffer underflow.885 * @param pTime The time spec.886 * @param psz Where to store the string.887 * @param cb The size of the buffer.888 */889 789 RTDECL(char *) RTTimeSpecToString(PCRTTIMESPEC pTime, char *psz, size_t cb) 890 790 { … … 896 796 897 797 898 /**899 * Attempts to convert an ISO date string to a time structure.900 *901 * We're a little forgiving with zero padding, unspecified parts, and leading902 * and trailing spaces.903 *904 * @retval pTime on success,905 * @retval NULL on failure.906 * @param pTime Where to store the time on success.907 * @param pszString The ISO date string to convert.908 */909 798 RTDECL(PRTTIME) RTTimeFromString(PRTTIME pTime, const char *pszString) 910 799 { … … 1072 961 1073 962 1074 /**1075 * Attempts to convert an ISO date string to a time structure.1076 *1077 * We're a little forgiving with zero padding, unspecified parts, and leading1078 * and trailing spaces.1079 *1080 * @retval pTime on success,1081 * @retval NULL on failure.1082 * @param pTime The time spec.1083 * @param pszString The ISO date string to convert.1084 */1085 963 RTDECL(PRTTIMESPEC) RTTimeSpecFromString(PRTTIMESPEC pTime, const char *pszString) 1086 964 { … … 1093 971 1094 972 1095 /**1096 * Formats the given time on a RTC-2822 compliant format.1097 *1098 * @returns Output string length on success (positive), VERR_BUFFER_OVERFLOW1099 * (negative) on failure.1100 * @param pTime The time. Caller should've normalized this.1101 * @param psz Where to store the string.1102 * @param cb The size of the buffer.1103 */1104 973 RTDECL(ssize_t) RTTimeToRfc2822(PRTTIME pTime, char *psz, size_t cb, uint32_t fFlags) 1105 974 { … … 1161 1030 1162 1031 1163 /**1164 * Attempts to convert an RFC-2822 date string to a time structure.1165 *1166 * We're a little forgiving with zero padding, unspecified parts, and leading1167 * and trailing spaces.1168 *1169 * @retval pTime on success,1170 * @retval NULL on failure.1171 * @param pTime Where to store the time on success.1172 * @param pszString The ISO date string to convert.1173 */1174 1032 RTDECL(PRTTIME) RTTimeFromRfc2822(PRTTIME pTime, const char *pszString) 1175 1033 { … … 1552 1410 1553 1411 1554 /**1555 * Converts a time structure to UTC, relying on UTC offset information if it contains local time.1556 *1557 * @returns pTime on success.1558 * @returns NULL if the data is invalid.1559 * @param pTime The time structure to convert.1560 */1561 1412 RTDECL(PRTTIME) RTTimeConvertToZulu(PRTTIME pTime) 1562 1413 { … … 1572 1423 1573 1424 1574 /**1575 * Compares two normalized time structures.1576 *1577 * @retval 0 if equal.1578 * @retval -1 if @a pLeft is earlier than @a pRight.1579 * @retval 1 if @a pRight is earlier than @a pLeft.1580 *1581 * @param pLeft The left side time. NULL is accepted.1582 * @param pRight The right side time. NULL is accepted.1583 *1584 * @note A NULL time is considered smaller than anything else. If both are1585 * NULL, they are considered equal.1586 */1587 1425 RTDECL(int) RTTimeCompare(PCRTTIME pLeft, PCRTTIME pRight) 1588 1426 {
Note:
See TracChangeset
for help on using the changeset viewer.