https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7e3826786eaec6f54cf6f…
commit 7e3826786eaec6f54cf6f2be1831dc9f106320a6
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Apr 16 11:10:00 2019 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Tue Apr 16 11:10:00 2019 +0900
[KERNEL32] Era first year is GANNEN
---
dll/win32/kernel32/winnls/string/japanese.c | 40 ++++++++++++++++++++++++++++-
dll/win32/kernel32/winnls/string/japanese.h | 1 +
dll/win32/kernel32/winnls/string/lcformat.c | 8 ++++++
3 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/dll/win32/kernel32/winnls/string/japanese.c
b/dll/win32/kernel32/winnls/string/japanese.c
index c3719f51f2..2edbdaeb88 100644
--- a/dll/win32/kernel32/winnls/string/japanese.c
+++ b/dll/win32/kernel32/winnls/string/japanese.c
@@ -53,6 +53,44 @@ static INT JapaneseEra_Compare(const void *e1, const void *e2)
return 0;
}
+BOOL JapaneseEra_IsFirstYearGannen(void)
+{
+#ifdef DONT_USE_REGISTRY
+ return TRUE;
+#else
+ HANDLE KeyHandle;
+ DWORD dwIndex;
+ WCHAR szName[32], szValue[32];
+ static BOOL s_bIsCached = FALSE, s_bFirstIsGannen = TRUE;
+
+ if (s_bIsCached)
+ return s_bFirstIsGannen;
+
+ KeyHandle = NLS_RegOpenKey(NULL, L"\\Registry\\Machine\\System\\"
+ L"CurrentControlSet\\Control\\Nls\\Calendars\\Japanese");
+ if (!KeyHandle)
+ return TRUE;
+
+ for (dwIndex = 0; dwIndex < 16; ++dwIndex)
+ {
+ if (!NLS_RegEnumValue(KeyHandle, dwIndex, szName, sizeof(szName),
+ szValue, sizeof(szValue)))
+ {
+ break;
+ }
+
+ if (lstrcmpiW(szName, L"InitialEraYear") == 0)
+ {
+ s_bFirstIsGannen = (szValue[0] == 0x5143);
+ s_bIsCached = TRUE;
+ break;
+ }
+ }
+
+ return s_bFirstIsGannen;
+#endif
+}
+
/*
* SEE ALSO:
*
https://en.wikipedia.org/wiki/Japanese_era_name
@@ -61,7 +99,7 @@ static INT JapaneseEra_Compare(const void *e1, const void *e2)
static PCJAPANESE_ERA JapaneseEra_Load(DWORD *pdwCount)
{
#ifndef DONT_USE_REGISTRY
- HANDLE KeyHandle = NULL;
+ HANDLE KeyHandle;
DWORD dwIndex;
WCHAR szName[128], szValue[128];
JAPANESE_ERA *pEntry;
diff --git a/dll/win32/kernel32/winnls/string/japanese.h
b/dll/win32/kernel32/winnls/string/japanese.h
index 747ee136ed..a4829bea69 100644
--- a/dll/win32/kernel32/winnls/string/japanese.h
+++ b/dll/win32/kernel32/winnls/string/japanese.h
@@ -18,4 +18,5 @@ typedef struct JAPANESE_ERA
} JAPANESE_ERA, *PJAPANESE_ERA;
typedef const JAPANESE_ERA *PCJAPANESE_ERA;
+BOOL JapaneseEra_IsFirstYearGannen(void);
PCJAPANESE_ERA JapaneseEra_Find(const SYSTEMTIME *pst OPTIONAL);
diff --git a/dll/win32/kernel32/winnls/string/lcformat.c
b/dll/win32/kernel32/winnls/string/lcformat.c
index 8d85351190..441c41b221 100644
--- a/dll/win32/kernel32/winnls/string/lcformat.c
+++ b/dll/win32/kernel32/winnls/string/lcformat.c
@@ -625,7 +625,15 @@ static INT NLS_GetDateTimeFormatW(LCID lcid, DWORD dwFlags,
{
count = 2;
}
+
dwVal = lpTime->wYear - pEra->wYear + 1;
+
+ if (dwVal == 1 && JapaneseEra_IsFirstYearGannen())
+ {
+ // Gan of 'Gannen'
+ buff[0] = 0x5143;
+ buff[1] = 0;
+ }
szAdd = buff;
break;
}