diff options
Diffstat (limited to 'chromium/third_party/icu/patches/persian_cal.patch')
-rw-r--r-- | chromium/third_party/icu/patches/persian_cal.patch | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/chromium/third_party/icu/patches/persian_cal.patch b/chromium/third_party/icu/patches/persian_cal.patch new file mode 100644 index 00000000000..d0014c4702d --- /dev/null +++ b/chromium/third_party/icu/patches/persian_cal.patch @@ -0,0 +1,51 @@ +diff --git a/source/i18n/gregoimp.cpp b/source/i18n/gregoimp.cpp +index e62044b3..537aa19d 100644 +--- a/source/i18n/gregoimp.cpp ++++ b/source/i18n/gregoimp.cpp +@@ -27,6 +27,11 @@ int32_t ClockMath::floorDivide(int32_t numerator, int32_t denominator) { + numerator / denominator : ((numerator + 1) / denominator) - 1; + } + ++int64_t ClockMath::floorDivide(int64_t numerator, int64_t denominator) { ++ return (numerator >= 0) ? ++ numerator / denominator : ((numerator + 1) / denominator) - 1; ++} ++ + int32_t ClockMath::floorDivide(double numerator, int32_t denominator, + int32_t& remainder) { + double quotient; +diff --git a/source/i18n/gregoimp.h b/source/i18n/gregoimp.h +index b3074167..afaacda0 100644 +--- a/source/i18n/gregoimp.h ++++ b/source/i18n/gregoimp.h +@@ -40,6 +40,17 @@ class ClockMath { + */ + static int32_t floorDivide(int32_t numerator, int32_t denominator); + ++ /** ++ * Divide two integers, returning the floor of the quotient. ++ * Unlike the built-in division, this is mathematically ++ * well-behaved. E.g., <code>-1/4</code> => 0 but ++ * <code>floorDivide(-1,4)</code> => -1. ++ * @param numerator the numerator ++ * @param denominator a divisor which must be != 0 ++ * @return the floor of the quotient ++ */ ++ static int64_t floorDivide(int64_t numerator, int64_t denominator); ++ + /** + * Divide two numbers, returning the floor of the quotient. + * Unlike the built-in division, this is mathematically +diff --git a/source/i18n/persncal.cpp b/source/i18n/persncal.cpp +index f66ac676..f38f779f 100644 +--- a/source/i18n/persncal.cpp ++++ b/source/i18n/persncal.cpp +@@ -213,7 +213,7 @@ void PersianCalendar::handleComputeFields(int32_t julianDay, UErrorCode &/*statu + int32_t year, month, dayOfMonth, dayOfYear; + + int32_t daysSinceEpoch = julianDay - PERSIAN_EPOCH; +- year = 1 + ClockMath::floorDivide(33 * daysSinceEpoch + 3, 12053); ++ year = 1 + (int32_t)ClockMath::floorDivide(33 * (int64_t)daysSinceEpoch + 3, (int64_t)12053); + + int32_t farvardin1 = 365 * (year - 1) + ClockMath::floorDivide(8 * year + 21, 33); + dayOfYear = (daysSinceEpoch - farvardin1); // 0-based |