OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "core/include/fxcrt/fx_ext.h" | 9 #include "core/include/fxcrt/fx_ext.h" |
10 #include "core/include/fxcrt/fx_xml.h" | 10 #include "core/include/fxcrt/fx_xml.h" |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 } else if (dwHash == FX_LOCALECATEGORY_NullHash) { | 622 } else if (dwHash == FX_LOCALECATEGORY_NullHash) { |
623 return FX_LOCALECATEGORY_Null; | 623 return FX_LOCALECATEGORY_Null; |
624 } | 624 } |
625 } else if (pStr[ccf] == '}') { | 625 } else if (pStr[ccf] == '}') { |
626 bBraceOpen = FALSE; | 626 bBraceOpen = FALSE; |
627 } | 627 } |
628 ccf++; | 628 ccf++; |
629 } | 629 } |
630 return eCategory; | 630 return eCategory; |
631 } | 631 } |
632 static FX_WORD FX_WStringToLCID(const FX_WCHAR* pstrLCID) { | 632 static uint16_t FX_WStringToLCID(const FX_WCHAR* pstrLCID) { |
633 if (!pstrLCID) { | 633 if (!pstrLCID) { |
634 return 0; | 634 return 0; |
635 } | 635 } |
636 wchar_t* pEnd; | 636 wchar_t* pEnd; |
637 return (FX_WORD)wcstol((wchar_t*)pstrLCID, &pEnd, 16); | 637 return (uint16_t)wcstol((wchar_t*)pstrLCID, &pEnd, 16); |
638 } | 638 } |
639 FX_WORD CFX_FormatString::GetLCID(const CFX_WideString& wsPattern) { | 639 uint16_t CFX_FormatString::GetLCID(const CFX_WideString& wsPattern) { |
640 return FX_WStringToLCID(GetLocaleName(wsPattern)); | 640 return FX_WStringToLCID(GetLocaleName(wsPattern)); |
641 } | 641 } |
642 CFX_WideString CFX_FormatString::GetLocaleName( | 642 CFX_WideString CFX_FormatString::GetLocaleName( |
643 const CFX_WideString& wsPattern) { | 643 const CFX_WideString& wsPattern) { |
644 int32_t ccf = 0; | 644 int32_t ccf = 0; |
645 int32_t iLenf = wsPattern.GetLength(); | 645 int32_t iLenf = wsPattern.GetLength(); |
646 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; | 646 const FX_WCHAR* pStr = (const FX_WCHAR*)wsPattern; |
647 while (ccf < iLenf) { | 647 while (ccf < iLenf) { |
648 if (pStr[ccf] == '\'') { | 648 if (pStr[ccf] == '\'') { |
649 FX_GetLiteralText(pStr, ccf, iLenf); | 649 FX_GetLiteralText(pStr, ccf, iLenf); |
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { | 2379 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { |
2380 if (!FX_IsDigit(str[cc])) { | 2380 if (!FX_IsDigit(str[cc])) { |
2381 return FALSE; | 2381 return FALSE; |
2382 } | 2382 } |
2383 month = str[cc++] - '0'; | 2383 month = str[cc++] - '0'; |
2384 if (cc < len) { | 2384 if (cc < len) { |
2385 month = month * 10 + str[cc++] - '0'; | 2385 month = month * 10 + str[cc++] - '0'; |
2386 } | 2386 } |
2387 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { | 2387 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { |
2388 CFX_WideString wsMonthNameAbbr; | 2388 CFX_WideString wsMonthNameAbbr; |
2389 FX_WORD i = 0; | 2389 uint16_t i = 0; |
2390 for (; i < 12; i++) { | 2390 for (; i < 12; i++) { |
2391 pLocale->GetMonthName(i, wsMonthNameAbbr, TRUE); | 2391 pLocale->GetMonthName(i, wsMonthNameAbbr, TRUE); |
2392 if (wsMonthNameAbbr.IsEmpty()) { | 2392 if (wsMonthNameAbbr.IsEmpty()) { |
2393 continue; | 2393 continue; |
2394 } | 2394 } |
2395 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthNameAbbr, str + cc, | 2395 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthNameAbbr, str + cc, |
2396 wsMonthNameAbbr.GetLength())) { | 2396 wsMonthNameAbbr.GetLength())) { |
2397 break; | 2397 break; |
2398 } | 2398 } |
2399 } | 2399 } |
2400 if (i < 12) { | 2400 if (i < 12) { |
2401 cc += wsMonthNameAbbr.GetLength(); | 2401 cc += wsMonthNameAbbr.GetLength(); |
2402 month = i + 1; | 2402 month = i + 1; |
2403 } | 2403 } |
2404 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { | 2404 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { |
2405 CFX_WideString wsMonthName; | 2405 CFX_WideString wsMonthName; |
2406 FX_WORD i = 0; | 2406 uint16_t i = 0; |
2407 for (; i < 12; i++) { | 2407 for (; i < 12; i++) { |
2408 pLocale->GetMonthName(i, wsMonthName, FALSE); | 2408 pLocale->GetMonthName(i, wsMonthName, FALSE); |
2409 if (wsMonthName.IsEmpty()) { | 2409 if (wsMonthName.IsEmpty()) { |
2410 continue; | 2410 continue; |
2411 } | 2411 } |
2412 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthName, str + cc, | 2412 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsMonthName, str + cc, |
2413 wsMonthName.GetLength())) { | 2413 wsMonthName.GetLength())) { |
2414 break; | 2414 break; |
2415 } | 2415 } |
2416 } | 2416 } |
2417 if (i < 12) { | 2417 if (i < 12) { |
2418 cc += wsMonthName.GetLength(); | 2418 cc += wsMonthName.GetLength(); |
2419 month = i + 1; | 2419 month = i + 1; |
2420 } | 2420 } |
2421 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { | 2421 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { |
2422 cc += 1; | 2422 cc += 1; |
2423 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { | 2423 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { |
2424 CFX_WideString wsDayNameAbbr; | 2424 CFX_WideString wsDayNameAbbr; |
2425 FX_WORD i = 0; | 2425 uint16_t i = 0; |
2426 for (; i < 7; i++) { | 2426 for (; i < 7; i++) { |
2427 pLocale->GetDayName(i, wsDayNameAbbr, TRUE); | 2427 pLocale->GetDayName(i, wsDayNameAbbr, TRUE); |
2428 if (wsDayNameAbbr.IsEmpty()) { | 2428 if (wsDayNameAbbr.IsEmpty()) { |
2429 continue; | 2429 continue; |
2430 } | 2430 } |
2431 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayNameAbbr, str + cc, | 2431 if (!FXSYS_wcsncmp((const FX_WCHAR*)wsDayNameAbbr, str + cc, |
2432 wsDayNameAbbr.GetLength())) { | 2432 wsDayNameAbbr.GetLength())) { |
2433 break; | 2433 break; |
2434 } | 2434 } |
2435 } | 2435 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2522 wMinute = iMinuteDiff % 60; | 2522 wMinute = iMinuteDiff % 60; |
2523 } | 2523 } |
2524 static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime, | 2524 static FX_BOOL FX_ParseLocaleTime(const CFX_WideString& wsTime, |
2525 const CFX_WideString& wsTimePattern, | 2525 const CFX_WideString& wsTimePattern, |
2526 IFX_Locale* pLocale, | 2526 IFX_Locale* pLocale, |
2527 CFX_Unitime& datetime, | 2527 CFX_Unitime& datetime, |
2528 int32_t& cc) { | 2528 int32_t& cc) { |
2529 uint8_t hour = 0; | 2529 uint8_t hour = 0; |
2530 uint8_t minute = 0; | 2530 uint8_t minute = 0; |
2531 uint8_t second = 0; | 2531 uint8_t second = 0; |
2532 FX_WORD millisecond = 0; | 2532 uint16_t millisecond = 0; |
2533 int32_t ccf = 0; | 2533 int32_t ccf = 0; |
2534 const FX_WCHAR* str = (const FX_WCHAR*)wsTime; | 2534 const FX_WCHAR* str = (const FX_WCHAR*)wsTime; |
2535 int len = wsTime.GetLength(); | 2535 int len = wsTime.GetLength(); |
2536 const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; | 2536 const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; |
2537 int lenf = wsTimePattern.GetLength(); | 2537 int lenf = wsTimePattern.GetLength(); |
2538 FX_BOOL bHasA = FALSE; | 2538 FX_BOOL bHasA = FALSE; |
2539 FX_BOOL bPM = FALSE; | 2539 FX_BOOL bPM = FALSE; |
2540 while (cc < len && ccf < lenf) { | 2540 while (cc < len && ccf < lenf) { |
2541 if (strf[ccf] == '\'') { | 2541 if (strf[ccf] == '\'') { |
2542 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); | 2542 CFX_WideString wsLiteral = FX_GetLiteralText(strf, ccf, lenf); |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3761 return FALSE; | 3761 return FALSE; |
3762 } | 3762 } |
3763 CFX_LCNumeric lcNum(fNum); | 3763 CFX_LCNumeric lcNum(fNum); |
3764 return FormatLCNumeric(lcNum, wsPattern, wsOutput); | 3764 return FormatLCNumeric(lcNum, wsPattern, wsOutput); |
3765 } | 3765 } |
3766 FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, | 3766 FX_BOOL FX_DateFromCanonical(const CFX_WideString& wsDate, |
3767 CFX_Unitime& datetime) { | 3767 CFX_Unitime& datetime) { |
3768 int32_t year = 1900; | 3768 int32_t year = 1900; |
3769 int32_t month = 1; | 3769 int32_t month = 1; |
3770 int32_t day = 1; | 3770 int32_t day = 1; |
3771 FX_WORD wYear = 0; | 3771 uint16_t wYear = 0; |
3772 int cc_start = 0, cc = 0; | 3772 int cc_start = 0, cc = 0; |
3773 const FX_WCHAR* str = (const FX_WCHAR*)wsDate; | 3773 const FX_WCHAR* str = (const FX_WCHAR*)wsDate; |
3774 int len = wsDate.GetLength(); | 3774 int len = wsDate.GetLength(); |
3775 if (len > 10) { | 3775 if (len > 10) { |
3776 return FALSE; | 3776 return FALSE; |
3777 } | 3777 } |
3778 while (cc < len && cc < 4) { | 3778 while (cc < len && cc < 4) { |
3779 if (!FX_IsDigit(str[cc])) { | 3779 if (!FX_IsDigit(str[cc])) { |
3780 return FALSE; | 3780 return FALSE; |
3781 } | 3781 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3844 } | 3844 } |
3845 FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime, | 3845 FX_BOOL FX_TimeFromCanonical(const CFX_WideStringC& wsTime, |
3846 CFX_Unitime& datetime, | 3846 CFX_Unitime& datetime, |
3847 IFX_Locale* pLocale) { | 3847 IFX_Locale* pLocale) { |
3848 if (wsTime.GetLength() == 0) { | 3848 if (wsTime.GetLength() == 0) { |
3849 return FALSE; | 3849 return FALSE; |
3850 } | 3850 } |
3851 uint8_t hour = 0; | 3851 uint8_t hour = 0; |
3852 uint8_t minute = 0; | 3852 uint8_t minute = 0; |
3853 uint8_t second = 0; | 3853 uint8_t second = 0; |
3854 FX_WORD millisecond = 0; | 3854 uint16_t millisecond = 0; |
3855 int cc_start = 0, cc = cc_start; | 3855 int cc_start = 0, cc = cc_start; |
3856 const FX_WCHAR* str = (const FX_WCHAR*)wsTime.GetPtr(); | 3856 const FX_WCHAR* str = (const FX_WCHAR*)wsTime.GetPtr(); |
3857 int len = wsTime.GetLength(); | 3857 int len = wsTime.GetLength(); |
3858 while (cc < len && cc < 2) { | 3858 while (cc < len && cc < 2) { |
3859 if (!FX_IsDigit(str[cc])) { | 3859 if (!FX_IsDigit(str[cc])) { |
3860 return FALSE; | 3860 return FALSE; |
3861 } | 3861 } |
3862 hour = hour * 10 + str[cc++] - '0'; | 3862 hour = hour * 10 + str[cc++] - '0'; |
3863 } | 3863 } |
3864 if (cc < 2 || hour >= 24) { | 3864 if (cc < 2 || hour >= 24) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3916 FX_ResolveZone(hour, minute, tzDiff, pLocale); | 3916 FX_ResolveZone(hour, minute, tzDiff, pLocale); |
3917 } | 3917 } |
3918 } | 3918 } |
3919 } | 3919 } |
3920 } | 3920 } |
3921 CFX_Unitime ut; | 3921 CFX_Unitime ut; |
3922 ut.Set(0, 0, 0, hour, minute, second, millisecond); | 3922 ut.Set(0, 0, 0, hour, minute, second, millisecond); |
3923 datetime = datetime + ut; | 3923 datetime = datetime + ut; |
3924 return TRUE; | 3924 return TRUE; |
3925 } | 3925 } |
3926 static FX_WORD FX_GetSolarMonthDays(FX_WORD year, FX_WORD month) { | 3926 static uint16_t FX_GetSolarMonthDays(uint16_t year, uint16_t month) { |
3927 if (month % 2) { | 3927 if (month % 2) { |
3928 return 31; | 3928 return 31; |
3929 } else if (month == 2) { | 3929 } else if (month == 2) { |
3930 return FX_IsLeapYear(year) ? 29 : 28; | 3930 return FX_IsLeapYear(year) ? 29 : 28; |
3931 } | 3931 } |
3932 return 30; | 3932 return 30; |
3933 } | 3933 } |
3934 static FX_WORD FX_GetWeekDay(FX_WORD year, FX_WORD month, FX_WORD day) { | 3934 static uint16_t FX_GetWeekDay(uint16_t year, uint16_t month, uint16_t day) { |
3935 FX_WORD g_month_day[] = {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5}; | 3935 uint16_t g_month_day[] = {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5}; |
3936 FX_WORD nDays = | 3936 uint16_t nDays = |
3937 (year - 1) % 7 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400; | 3937 (year - 1) % 7 + (year - 1) / 4 - (year - 1) / 100 + (year - 1) / 400; |
3938 nDays += g_month_day[month - 1] + day; | 3938 nDays += g_month_day[month - 1] + day; |
3939 if (FX_IsLeapYear(year) && month > 2) { | 3939 if (FX_IsLeapYear(year) && month > 2) { |
3940 nDays++; | 3940 nDays++; |
3941 } | 3941 } |
3942 return nDays % 7; | 3942 return nDays % 7; |
3943 } | 3943 } |
3944 static FX_WORD FX_GetWeekOfMonth(FX_WORD year, FX_WORD month, FX_WORD day) { | 3944 static uint16_t FX_GetWeekOfMonth(uint16_t year, uint16_t month, uint16_t day) { |
3945 FX_WORD week_day = FX_GetWeekDay(year, month, 1); | 3945 uint16_t week_day = FX_GetWeekDay(year, month, 1); |
3946 FX_WORD week_index = 0; | 3946 uint16_t week_index = 0; |
3947 week_index += day / 7; | 3947 week_index += day / 7; |
3948 day = day % 7; | 3948 day = day % 7; |
3949 if (week_day + day > 7) { | 3949 if (week_day + day > 7) { |
3950 week_index++; | 3950 week_index++; |
3951 } | 3951 } |
3952 return week_index; | 3952 return week_index; |
3953 } | 3953 } |
3954 static FX_WORD FX_GetWeekOfYear(FX_WORD year, FX_WORD month, FX_WORD day) { | 3954 static uint16_t FX_GetWeekOfYear(uint16_t year, uint16_t month, uint16_t day) { |
3955 FX_WORD nDays = 0; | 3955 uint16_t nDays = 0; |
3956 for (FX_WORD i = 1; i < month; i++) { | 3956 for (uint16_t i = 1; i < month; i++) { |
3957 nDays += FX_GetSolarMonthDays(year, i); | 3957 nDays += FX_GetSolarMonthDays(year, i); |
3958 } | 3958 } |
3959 nDays += day; | 3959 nDays += day; |
3960 FX_WORD week_day = FX_GetWeekDay(year, 1, 1); | 3960 uint16_t week_day = FX_GetWeekDay(year, 1, 1); |
3961 FX_WORD week_index = 1; | 3961 uint16_t week_index = 1; |
3962 week_index += nDays / 7; | 3962 week_index += nDays / 7; |
3963 nDays = nDays % 7; | 3963 nDays = nDays % 7; |
3964 if (week_day + nDays > 7) { | 3964 if (week_day + nDays > 7) { |
3965 week_index++; | 3965 week_index++; |
3966 } | 3966 } |
3967 return week_index; | 3967 return week_index; |
3968 } | 3968 } |
3969 static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern, | 3969 static FX_BOOL FX_DateFormat(const CFX_WideString& wsDatePattern, |
3970 IFX_Locale* pLocale, | 3970 IFX_Locale* pLocale, |
3971 const CFX_Unitime& datetime, | 3971 const CFX_Unitime& datetime, |
(...skipping 23 matching lines...) Expand all Loading... |
3995 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); | 3995 dwSymbol = (dwSymbol << 8) | (dwSymbolNum + '0'); |
3996 if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { | 3996 if (dwSymbol == FXBSTR_ID(0, 0, 'D', '1')) { |
3997 CFX_WideString wsDay; | 3997 CFX_WideString wsDay; |
3998 wsDay.Format(L"%d", day); | 3998 wsDay.Format(L"%d", day); |
3999 wsResult += wsDay; | 3999 wsResult += wsDay; |
4000 } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { | 4000 } else if (dwSymbol == FXBSTR_ID(0, 0, 'D', '2')) { |
4001 CFX_WideString wsDay; | 4001 CFX_WideString wsDay; |
4002 wsDay.Format(L"%02d", day); | 4002 wsDay.Format(L"%02d", day); |
4003 wsResult += wsDay; | 4003 wsResult += wsDay; |
4004 } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) { | 4004 } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '1')) { |
4005 FX_WORD nDays = 0; | 4005 uint16_t nDays = 0; |
4006 for (int i = 1; i < month; i++) { | 4006 for (int i = 1; i < month; i++) { |
4007 nDays += FX_GetSolarMonthDays(year, i); | 4007 nDays += FX_GetSolarMonthDays(year, i); |
4008 } | 4008 } |
4009 nDays += day; | 4009 nDays += day; |
4010 CFX_WideString wsDays; | 4010 CFX_WideString wsDays; |
4011 wsDays.Format(L"%d", nDays); | 4011 wsDays.Format(L"%d", nDays); |
4012 wsResult += wsDays; | 4012 wsResult += wsDays; |
4013 } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) { | 4013 } else if (dwSymbol == FXBSTR_ID(0, 0, 'J', '3')) { |
4014 FX_WORD nDays = 0; | 4014 uint16_t nDays = 0; |
4015 for (int i = 1; i < month; i++) { | 4015 for (int i = 1; i < month; i++) { |
4016 nDays += FX_GetSolarMonthDays(year, i); | 4016 nDays += FX_GetSolarMonthDays(year, i); |
4017 } | 4017 } |
4018 nDays += day; | 4018 nDays += day; |
4019 CFX_WideString wsDays; | 4019 CFX_WideString wsDays; |
4020 wsDays.Format(L"%03d", nDays); | 4020 wsDays.Format(L"%03d", nDays); |
4021 wsResult += wsDays; | 4021 wsResult += wsDays; |
4022 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { | 4022 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '1')) { |
4023 CFX_WideString wsMonth; | 4023 CFX_WideString wsMonth; |
4024 wsMonth.Format(L"%d", month); | 4024 wsMonth.Format(L"%d", month); |
4025 wsResult += wsMonth; | 4025 wsResult += wsMonth; |
4026 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { | 4026 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '2')) { |
4027 CFX_WideString wsMonth; | 4027 CFX_WideString wsMonth; |
4028 wsMonth.Format(L"%02d", month); | 4028 wsMonth.Format(L"%02d", month); |
4029 wsResult += wsMonth; | 4029 wsResult += wsMonth; |
4030 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { | 4030 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '3')) { |
4031 CFX_WideString wsTemp; | 4031 CFX_WideString wsTemp; |
4032 pLocale->GetMonthName(month - 1, wsTemp, TRUE); | 4032 pLocale->GetMonthName(month - 1, wsTemp, TRUE); |
4033 wsResult += wsTemp; | 4033 wsResult += wsTemp; |
4034 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { | 4034 } else if (dwSymbol == FXBSTR_ID(0, 0, 'M', '4')) { |
4035 CFX_WideString wsTemp; | 4035 CFX_WideString wsTemp; |
4036 pLocale->GetMonthName(month - 1, wsTemp, FALSE); | 4036 pLocale->GetMonthName(month - 1, wsTemp, FALSE); |
4037 wsResult += wsTemp; | 4037 wsResult += wsTemp; |
4038 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { | 4038 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '1')) { |
4039 FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); | 4039 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); |
4040 CFX_WideString wsWeekDay; | 4040 CFX_WideString wsWeekDay; |
4041 wsWeekDay.Format(L"%d", wWeekDay + 1); | 4041 wsWeekDay.Format(L"%d", wWeekDay + 1); |
4042 wsResult += wsWeekDay; | 4042 wsResult += wsWeekDay; |
4043 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { | 4043 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '3')) { |
4044 FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); | 4044 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); |
4045 CFX_WideString wsTemp; | 4045 CFX_WideString wsTemp; |
4046 pLocale->GetDayName(wWeekDay, wsTemp, TRUE); | 4046 pLocale->GetDayName(wWeekDay, wsTemp, TRUE); |
4047 wsResult += wsTemp; | 4047 wsResult += wsTemp; |
4048 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { | 4048 } else if (dwSymbol == FXBSTR_ID(0, 0, 'E', '4')) { |
4049 FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); | 4049 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); |
4050 if (pLocale) { | 4050 if (pLocale) { |
4051 CFX_WideString wsTemp; | 4051 CFX_WideString wsTemp; |
4052 pLocale->GetDayName(wWeekDay, wsTemp, FALSE); | 4052 pLocale->GetDayName(wWeekDay, wsTemp, FALSE); |
4053 wsResult += wsTemp; | 4053 wsResult += wsTemp; |
4054 } | 4054 } |
4055 } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { | 4055 } else if (dwSymbol == FXBSTR_ID(0, 0, 'e', '1')) { |
4056 FX_WORD wWeekDay = FX_GetWeekDay(year, month, day); | 4056 uint16_t wWeekDay = FX_GetWeekDay(year, month, day); |
4057 CFX_WideString wsWeekDay; | 4057 CFX_WideString wsWeekDay; |
4058 wsWeekDay.Format(L"%d", wWeekDay ? wWeekDay : 7); | 4058 wsWeekDay.Format(L"%d", wWeekDay ? wWeekDay : 7); |
4059 wsResult += wsWeekDay; | 4059 wsResult += wsWeekDay; |
4060 } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { | 4060 } else if (dwSymbol == FXBSTR_ID(0, 0, 'G', '1')) { |
4061 CFX_WideString wsTemp; | 4061 CFX_WideString wsTemp; |
4062 pLocale->GetEraName(wsTemp, year < 0); | 4062 pLocale->GetEraName(wsTemp, year < 0); |
4063 wsResult += wsTemp; | 4063 wsResult += wsTemp; |
4064 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) { | 4064 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '2')) { |
4065 CFX_WideString wsYear; | 4065 CFX_WideString wsYear; |
4066 wsYear.Format(L"%02d", year % 100); | 4066 wsYear.Format(L"%02d", year % 100); |
4067 wsResult += wsYear; | 4067 wsResult += wsYear; |
4068 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '4')) { | 4068 } else if (dwSymbol == FXBSTR_ID(0, 0, 'Y', '4')) { |
4069 CFX_WideString wsYear; | 4069 CFX_WideString wsYear; |
4070 wsYear.Format(L"%d", year); | 4070 wsYear.Format(L"%d", year); |
4071 wsResult += wsYear; | 4071 wsResult += wsYear; |
4072 } else if (dwSymbol == FXBSTR_ID(0, 0, 'w', '1')) { | 4072 } else if (dwSymbol == FXBSTR_ID(0, 0, 'w', '1')) { |
4073 FX_WORD week_index = FX_GetWeekOfMonth(year, month, day); | 4073 uint16_t week_index = FX_GetWeekOfMonth(year, month, day); |
4074 CFX_WideString wsWeekInMonth; | 4074 CFX_WideString wsWeekInMonth; |
4075 wsWeekInMonth.Format(L"%d", week_index); | 4075 wsWeekInMonth.Format(L"%d", week_index); |
4076 wsResult += wsWeekInMonth; | 4076 wsResult += wsWeekInMonth; |
4077 } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { | 4077 } else if (dwSymbol == FXBSTR_ID(0, 0, 'W', '2')) { |
4078 FX_WORD week_index = FX_GetWeekOfYear(year, month, day); | 4078 uint16_t week_index = FX_GetWeekOfYear(year, month, day); |
4079 CFX_WideString wsWeekInYear; | 4079 CFX_WideString wsWeekInYear; |
4080 wsWeekInYear.Format(L"%02d", week_index); | 4080 wsWeekInYear.Format(L"%02d", week_index); |
4081 wsResult += wsWeekInYear; | 4081 wsResult += wsWeekInYear; |
4082 } | 4082 } |
4083 } | 4083 } |
4084 return bRet; | 4084 return bRet; |
4085 } | 4085 } |
4086 static FX_BOOL FX_TimeFormat(const CFX_WideString& wsTimePattern, | 4086 static FX_BOOL FX_TimeFormat(const CFX_WideString& wsTimePattern, |
4087 IFX_Locale* pLocale, | 4087 IFX_Locale* pLocale, |
4088 const CFX_Unitime& datetime, | 4088 const CFX_Unitime& datetime, |
4089 CFX_WideString& wsResult) { | 4089 CFX_WideString& wsResult) { |
4090 FX_BOOL bGMT = FALSE; | 4090 FX_BOOL bGMT = FALSE; |
4091 FX_BOOL bRet = TRUE; | 4091 FX_BOOL bRet = TRUE; |
4092 uint8_t hour = datetime.GetHour(); | 4092 uint8_t hour = datetime.GetHour(); |
4093 uint8_t minute = datetime.GetMinute(); | 4093 uint8_t minute = datetime.GetMinute(); |
4094 uint8_t second = datetime.GetSecond(); | 4094 uint8_t second = datetime.GetSecond(); |
4095 FX_WORD millisecond = datetime.GetMillisecond(); | 4095 uint16_t millisecond = datetime.GetMillisecond(); |
4096 int32_t ccf = 0; | 4096 int32_t ccf = 0; |
4097 const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; | 4097 const FX_WCHAR* strf = (const FX_WCHAR*)wsTimePattern; |
4098 int32_t lenf = wsTimePattern.GetLength(); | 4098 int32_t lenf = wsTimePattern.GetLength(); |
4099 FX_WORD wHour = hour; | 4099 uint16_t wHour = hour; |
4100 FX_BOOL bPM = FALSE; | 4100 FX_BOOL bPM = FALSE; |
4101 if (wsTimePattern.Find('A') != -1) { | 4101 if (wsTimePattern.Find('A') != -1) { |
4102 if (wHour >= 12) { | 4102 if (wHour >= 12) { |
4103 bPM = TRUE; | 4103 bPM = TRUE; |
4104 } | 4104 } |
4105 } | 4105 } |
4106 while (ccf < lenf) { | 4106 while (ccf < lenf) { |
4107 if (strf[ccf] == '\'') { | 4107 if (strf[ccf] == '\'') { |
4108 wsResult += FX_GetLiteralText(strf, ccf, lenf); | 4108 wsResult += FX_GetLiteralText(strf, ccf, lenf); |
4109 ccf++; | 4109 ccf++; |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5021 } | 5021 } |
5022 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { | 5022 CFX_Decimal CFX_Decimal::operator*(const CFX_Decimal& val) const { |
5023 return Multiply(val); | 5023 return Multiply(val); |
5024 } | 5024 } |
5025 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { | 5025 CFX_Decimal CFX_Decimal::operator/(const CFX_Decimal& val) const { |
5026 return Divide(val); | 5026 return Divide(val); |
5027 } | 5027 } |
5028 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { | 5028 CFX_Decimal CFX_Decimal::operator%(const CFX_Decimal& val) const { |
5029 return Modulus(val); | 5029 return Modulus(val); |
5030 } | 5030 } |
OLD | NEW |