Ticket #13689: 0001-BDateFormat-Properly-map-day-values-to-ICU-day-of-we.patch

File 0001-BDateFormat-Properly-map-day-values-to-ICU-day-of-we.patch, 1.3 KB (added by akshay, 7 years ago)
  • headers/os/locale/DateFormat.h

    From b85f9f9a122cca724645fb0c499df7ba33d420e1 Mon Sep 17 00:00:00 2001
    From: Akshay Agarwal <agarwal.akshay.akshay8@gmail.com>
    Date: Mon, 4 Sep 2017 12:54:28 +0530
    Subject: [PATCH] BDateFormat: Properly map day values to ICU day-of-week.
    
    ---
     headers/os/locale/DateFormat.h | 9 +++++++++
     src/kits/locale/DateFormat.cpp | 2 +-
     2 files changed, 10 insertions(+), 1 deletion(-)
    
    diff --git a/headers/os/locale/DateFormat.h b/headers/os/locale/DateFormat.h
    index 2f9aad0..cee04e5 100644
    a b public:  
    8484                                    BDate& output);
    8585
    8686private:
     87            int                 _ConvertDayNumberToICU(int day) const;
     88
    8789            U_ICU_NAMESPACE::DateFormat*    _CreateDateFormatter(
    8890                                    const BDateFormatStyle style) const;
    8991
    9092};
    9193
    9294
     95inline int
     96BDateFormat::_ConvertDayNumberToICU(int day) const
     97{
     98    return day == 7 ? 1 : day + 1;
     99}
     100
     101
    93102#endif  // _B_DATE_FORMAT_H_
  • src/kits/locale/DateFormat.cpp

    diff --git a/src/kits/locale/DateFormat.cpp b/src/kits/locale/DateFormat.cpp
    index 09fe428..b70d601 100644
    a b BDateFormat::GetDayName(int day, BString& outName,  
    366366    }
    367367
    368368    BStringByteSink stringConverter(&outName);
    369     names[day].toUTF8(stringConverter);
     369    names[_ConvertDayNumberToICU(day)].toUTF8(stringConverter);
    370370
    371371    delete simpleFormat;
    372372    return B_OK;